gitea-github-proxy/api/routes_app.go

37 lines
945 B
Go

package api
import (
"git.lumeweb.com/LumeWeb/gitea-github-proxy/config"
"go.uber.org/zap"
"net/http"
)
type appApi struct {
config *config.Config
logger *zap.Logger
}
func newAppApi(cfg *config.Config, logger *zap.Logger) *appApi {
return &appApi{config: cfg, logger: logger}
}
func (a *appApi) handlerNewAppInstall(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("App installations are not needed on this proxy. All webhooks are broadcasted to all registered apps."))
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "text/plain")
}
func setupAppRoutes(params RouteParams) {
logger := params.Logger
cfg := params.Config
r := params.R
appApi := newAppApi(cfg, logger)
appRouter := r.PathPrefix("/apps").Subrouter()
appRouter.Use(giteaOauthVerifyMiddleware(cfg))
appRouter.Use(requireAuthMiddleware(cfg))
appRouter.HandleFunc("/{app}/installations/new", appApi.handlerNewAppInstall).Methods("GET")
}