mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-27 02:40:30 +00:00
create web package
This commit is contained in:
parent
0ee1e4f0da
commit
8251663686
7 changed files with 33 additions and 33 deletions
|
@ -7,13 +7,13 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/drone/drone/api"
|
||||
"github.com/drone/drone/controller"
|
||||
"github.com/drone/drone/router/middleware/header"
|
||||
"github.com/drone/drone/router/middleware/location"
|
||||
"github.com/drone/drone/router/middleware/session"
|
||||
"github.com/drone/drone/router/middleware/token"
|
||||
"github.com/drone/drone/static"
|
||||
"github.com/drone/drone/template"
|
||||
"github.com/drone/drone/web"
|
||||
)
|
||||
|
||||
func Load(middleware ...gin.HandlerFunc) http.Handler {
|
||||
|
@ -29,17 +29,17 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||
e.Use(session.SetUser())
|
||||
e.Use(token.Refresh)
|
||||
|
||||
e.GET("/", controller.ShowIndex)
|
||||
e.GET("/login", controller.ShowLogin)
|
||||
e.GET("/login/form", controller.ShowLoginForm)
|
||||
e.GET("/logout", controller.GetLogout)
|
||||
e.GET("/", web.ShowIndex)
|
||||
e.GET("/login", web.ShowLogin)
|
||||
e.GET("/login/form", web.ShowLoginForm)
|
||||
e.GET("/logout", web.GetLogout)
|
||||
|
||||
settings := e.Group("/settings")
|
||||
{
|
||||
settings.Use(session.MustUser())
|
||||
settings.GET("/profile", controller.ShowUser)
|
||||
settings.GET("/people", session.MustAdmin(), controller.ShowUsers)
|
||||
settings.GET("/nodes", session.MustAdmin(), controller.ShowNodes)
|
||||
settings.GET("/profile", web.ShowUser)
|
||||
settings.GET("/people", session.MustAdmin(), web.ShowUsers)
|
||||
settings.GET("/nodes", session.MustAdmin(), web.ShowNodes)
|
||||
}
|
||||
repo := e.Group("/repos/:owner/:name")
|
||||
{
|
||||
|
@ -47,14 +47,14 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||
repo.Use(session.SetPerm())
|
||||
repo.Use(session.MustPull)
|
||||
|
||||
repo.GET("", controller.ShowRepo)
|
||||
repo.GET("/builds/:number", controller.ShowBuild)
|
||||
repo.GET("/builds/:number/:job", controller.ShowBuild)
|
||||
repo.GET("", web.ShowRepo)
|
||||
repo.GET("/builds/:number", web.ShowBuild)
|
||||
repo.GET("/builds/:number/:job", web.ShowBuild)
|
||||
repo_settings := repo.Group("/settings")
|
||||
{
|
||||
repo_settings.GET("", session.MustPush, controller.ShowRepoConf)
|
||||
repo_settings.GET("/encrypt", session.MustPush, controller.ShowRepoEncrypt)
|
||||
repo_settings.GET("/badges", controller.ShowRepoBadges)
|
||||
repo_settings.GET("", session.MustPush, web.ShowRepoConf)
|
||||
repo_settings.GET("/encrypt", session.MustPush, web.ShowRepoEncrypt)
|
||||
repo_settings.GET("/badges", web.ShowRepoBadges)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,39 +117,39 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||
|
||||
badges := e.Group("/api/badges/:owner/:name")
|
||||
{
|
||||
badges.GET("/status.svg", controller.GetBadge)
|
||||
badges.GET("/cc.xml", controller.GetCC)
|
||||
badges.GET("/status.svg", web.GetBadge)
|
||||
badges.GET("/cc.xml", web.GetCC)
|
||||
}
|
||||
|
||||
e.POST("/hook", controller.PostHook)
|
||||
e.POST("/api/hook", controller.PostHook)
|
||||
e.POST("/hook", web.PostHook)
|
||||
e.POST("/api/hook", web.PostHook)
|
||||
|
||||
stream := e.Group("/api/stream")
|
||||
{
|
||||
stream.Use(session.SetRepo())
|
||||
stream.Use(session.SetPerm())
|
||||
stream.Use(session.MustPull)
|
||||
stream.GET("/:owner/:name", controller.GetRepoEvents)
|
||||
stream.GET("/:owner/:name/:build/:number", controller.GetStream)
|
||||
stream.GET("/:owner/:name", web.GetRepoEvents)
|
||||
stream.GET("/:owner/:name/:build/:number", web.GetStream)
|
||||
}
|
||||
|
||||
auth := e.Group("/authorize")
|
||||
{
|
||||
auth.GET("", controller.GetLogin)
|
||||
auth.POST("", controller.GetLogin)
|
||||
auth.POST("/token", controller.GetLoginToken)
|
||||
auth.GET("", web.GetLogin)
|
||||
auth.POST("", web.GetLogin)
|
||||
auth.POST("/token", web.GetLoginToken)
|
||||
}
|
||||
|
||||
gitlab := e.Group("/gitlab/:owner/:name")
|
||||
{
|
||||
gitlab.Use(session.SetRepo())
|
||||
gitlab.GET("/commits/:sha", controller.GetCommit)
|
||||
gitlab.GET("/pulls/:number", controller.GetPullRequest)
|
||||
gitlab.GET("/commits/:sha", web.GetCommit)
|
||||
gitlab.GET("/pulls/:number", web.GetPullRequest)
|
||||
|
||||
redirects := gitlab.Group("/redirect")
|
||||
{
|
||||
redirects.GET("/commits/:sha", controller.RedirectSha)
|
||||
redirects.GET("/pulls/:number", controller.RedirectPullRequest)
|
||||
redirects.GET("/commits/:sha", web.RedirectSha)
|
||||
redirects.GET("/pulls/:number", web.RedirectPullRequest)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package controller
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package controller
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package controller
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package controller
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package controller
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package controller
|
||||
package web
|
||||
|
||||
import (
|
||||
"io"
|
Loading…
Reference in a new issue