2024-02-11 04:50:46 +00:00
|
|
|
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")
|
|
|
|
}
|
2024-02-11 05:15:57 +00:00
|
|
|
|
|
|
|
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")
|
|
|
|
}
|