Moved around more code. Implemented more sqlc. Added support to generate swagger.
Added support for profiling. Removed the pkg module altogether. Everything except old sync is now using code generated by sqlc.
This commit is contained in:
@@ -7,9 +7,13 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
_ "music-server/cmd/docs"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/echo/middleware"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
echoSwagger "github.com/swaggo/echo-swagger" // echo-swagger middleware
|
||||
//_ "github.com/swaggo/echo-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.
|
||||
)
|
||||
|
||||
func (s *Server) RegisterRoutes() http.Handler {
|
||||
@@ -36,9 +40,17 @@ func (s *Server) RegisterRoutes() http.Handler {
|
||||
swagger := http.FileServer(http.FS(web.Swagger))
|
||||
e.GET("/swagger/*", echo.WrapHandler(swagger))
|
||||
|
||||
swaggerRedirect := func(c echo.Context) error {
|
||||
return c.Redirect(http.StatusMovedPermanently, "/doc/index.html")
|
||||
}
|
||||
e.GET("/doc", swaggerRedirect)
|
||||
e.GET("/doc/", swaggerRedirect)
|
||||
e.GET("/doc/*", echoSwagger.WrapHandler)
|
||||
|
||||
index := NewIndexHandler()
|
||||
e.GET("/version", index.GetVersion)
|
||||
e.GET("/health", index.GetDBTest)
|
||||
e.GET("/dbtest", index.GetDBTest)
|
||||
e.GET("/health", index.HealthCheck)
|
||||
e.GET("/character", index.GetCharacter)
|
||||
e.GET("/characters", index.GetCharacters)
|
||||
|
||||
@@ -78,6 +90,5 @@ func (s *Server) RegisterRoutes() http.Handler {
|
||||
fmt.Printf(" %s %s\n", r.Method, r.Path)
|
||||
}
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user