tsk-15: Add API documentation (#17)
Closes #15 Reviewed-on: phoenix/textsender-auth#17 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -12,7 +12,9 @@ import (
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/swaggo/http-swagger/v2"
|
||||
|
||||
_ "git.kundeng.us/phoenix/textsender-auth/docs"
|
||||
"git.kundeng.us/phoenix/textsender-auth/internal/config"
|
||||
database "git.kundeng.us/phoenix/textsender-auth/internal/db"
|
||||
"git.kundeng.us/phoenix/textsender-auth/internal/handler"
|
||||
@@ -21,6 +23,17 @@ import (
|
||||
"git.kundeng.us/phoenix/textsender-auth/internal/model"
|
||||
)
|
||||
|
||||
// @title textsender-auth
|
||||
// @version 1.0
|
||||
// @description Auth API to send text messages
|
||||
|
||||
// @host localhost:9080
|
||||
// @BasePath /api/v1
|
||||
|
||||
// @securityDefinitions.apikey BearerAuth
|
||||
// @in header
|
||||
// @name Authorization
|
||||
// @description JWT Bearer Token
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
if cfg == nil {
|
||||
@@ -73,6 +86,10 @@ func main() {
|
||||
router.Method("Post", endpoint.Register, http.HandlerFunc(userHandler.Register))
|
||||
router.Method("Post", endpoint.Login, http.HandlerFunc(loginHandler.Login))
|
||||
|
||||
router.Method("GET", "/swagger/*", httpSwagger.Handler(
|
||||
httpSwagger.URL(fmt.Sprintf("http://localhost:%s/swagger/doc.json", config.Port)),
|
||||
))
|
||||
|
||||
// Start server
|
||||
server := &http.Server{
|
||||
Addr: ":" + cfg.ServerPort,
|
||||
|
||||
Reference in New Issue
Block a user