Skip to content

Subrouters? #102

Answered by vearutop
peterkuykendall asked this question in Q&A
Dec 1, 2022 · 1 comments · 1 reply

You must be logged in to vote

Hello, please check https://github.com/swaggest/rest/blob/master/_examples/mount/main.go if it fits your case.

	service := web.DefaultService()
	service.OpenAPI.Info.Title = "Security and Mount Example"

	apiV1 := web.DefaultService()

	apiV1.Wrap(
		middleware.BasicAuth("Admin Access", map[string]string{"admin": "admin"}),
		nethttp.HTTPBasicSecurityMiddleware(service.OpenAPICollector, "Admin", "Admin access"),
	)

	apiV1.Post("/sum", sum())
	apiV1.Post("/mul", mul())

	service.Mount("/api/v1", apiV1)
	service.Docs("/api/v1/docs", swgui.New)

	// Blanket handler, for example to serve static content.
	service.Mount("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		_, _ =

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@peterkuykendall

Answer selected by peterkuykendall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants