feat: add env vars to disable render endpoints
BLOCKY_DISABLE_GLB/PNG/GIF/MP4 return 403 when set to true
This commit is contained in:
parent
ce511e1a85
commit
f8947fdcc4
5 changed files with 110 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"blockyserver/internal/config"
|
||||
"blockyserver/internal/service"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
|
@ -19,6 +20,10 @@ func NewServer(svc *service.MergeService) http.Handler {
|
|||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.Timeout(60 * time.Second))
|
||||
|
||||
// Load endpoint config
|
||||
cfg := config.LoadEndpointConfig()
|
||||
guards := NewEndpointGuards(cfg)
|
||||
|
||||
// Create handlers
|
||||
h := NewHandlers(svc)
|
||||
|
||||
|
|
@ -26,10 +31,10 @@ func NewServer(svc *service.MergeService) http.Handler {
|
|||
r.Get("/health", h.HandleHealth)
|
||||
r.Get("/openapi.json", h.HandleOpenAPISpec)
|
||||
r.Get("/docs", h.HandleSwaggerUI)
|
||||
r.Post("/render/glb", h.HandleGLB)
|
||||
r.Post("/render/png", h.HandlePNG)
|
||||
r.Post("/render/gif", h.HandleGIF)
|
||||
r.Post("/render/mp4", h.HandleMP4)
|
||||
r.With(guards["glb"]).Post("/render/glb", h.HandleGLB)
|
||||
r.With(guards["png"]).Post("/render/png", h.HandlePNG)
|
||||
r.With(guards["gif"]).Post("/render/gif", h.HandleGIF)
|
||||
r.With(guards["mp4"]).Post("/render/mp4", h.HandleMP4)
|
||||
|
||||
return r
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue