add swagger
This commit is contained in:
@@ -11,12 +11,14 @@ import (
|
||||
api_acladmin "git.oblat.lv/alex/triggerssmith/api/acl_admin"
|
||||
api_auth "git.oblat.lv/alex/triggerssmith/api/auth"
|
||||
api_block "git.oblat.lv/alex/triggerssmith/api/block"
|
||||
_ "git.oblat.lv/alex/triggerssmith/docs"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/acl"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/auth"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/config"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/vars"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
httpSwagger "github.com/swaggo/http-swagger"
|
||||
)
|
||||
|
||||
type Router struct {
|
||||
@@ -66,7 +68,7 @@ func (r *Router) MustRoute() chi.Router {
|
||||
slog.String("dir", r.cfg.Server.StaticConfig.Dir),
|
||||
slog.String("index_file", r.cfg.Server.StaticConfig.IndexFile),
|
||||
)
|
||||
r.r.Get("/", func(w http.ResponseWriter, req *http.Request) {
|
||||
r.r.Get("/*", func(w http.ResponseWriter, req *http.Request) {
|
||||
http.ServeFile(w, req, filepath.Join(r.cfg.Server.StaticConfig.Dir, r.cfg.Server.StaticConfig.IndexFile))
|
||||
})
|
||||
fs := http.FileServer(http.Dir(r.cfg.Server.StaticConfig.Dir))
|
||||
@@ -82,6 +84,9 @@ func (r *Router) MustRoute() chi.Router {
|
||||
}
|
||||
|
||||
r.r.Route("/api", func(api chi.Router) {
|
||||
api.Get("/swagger/*", httpSwagger.Handler(
|
||||
httpSwagger.URL("/api/swagger/doc.json"),
|
||||
))
|
||||
api.Route("/block", api_block.MustRoute(r.cfg))
|
||||
authRoute := api_auth.MustRoute(r.cfg, r.authService)
|
||||
api.Route("/auth", authRoute)
|
||||
|
||||
Reference in New Issue
Block a user