Skip to content

Commit

Permalink
setup handler
Browse files Browse the repository at this point in the history
  • Loading branch information
boddumanohar committed Feb 5, 2023
1 parent 83870e5 commit 069f2d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions code/go/0chain.net/blobber/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ func initHandlers(r *mux.Router) {
handler.StartTime = time.Now().UTC()
r.HandleFunc("/", handler.HomepageHandler)
handler.SetupHandlers(r)
handler.SetupSwagger()
common.SetAdminCredentials()
}
9 changes: 3 additions & 6 deletions code/go/0chain.net/blobbercore/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,24 @@ func RateLimitByGeneralRL(handler common.ReqRespHandlerf) common.ReqRespHandlerf
}

func SetupSwagger() {
mux := http.NewServeMux()
mux.Handle("/swagger.yaml", http.FileServer(http.Dir("/docs")))
http.Handle("/swagger.yaml", http.FileServer(http.Dir("/docs")))

// documentation for developers
opts := middleware.SwaggerUIOpts{SpecURL: "swagger.yaml"}
sh := middleware.SwaggerUI(opts, nil)
mux.Handle("/docs", sh)
http.Handle("/docs", sh)

// documentation for share
opts1 := middleware.RedocOpts{SpecURL: "swagger.yaml", Path: "docs1"}
sh1 := middleware.Redoc(opts1, nil)
mux.Handle("/docs1", sh1)
http.Handle("/docs1", sh1)
}

/*setupHandlers sets up the necessary API end points */
func setupHandlers(r *mux.Router) {
ConfigRateLimits()
r.Use(useRecovery, useCors)

SetupSwagger()

//object operations
r.HandleFunc("/v1/file/rename/{allocation}",
RateLimitByGeneralRL(common.ToJSONResponse(WithConnection(RenameHandler)))).
Expand Down

0 comments on commit 069f2d8

Please sign in to comment.