You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to use swaggest in my project today and I can't get the swaggest URL's to play nice with static files.
My goal was to have /api/... and /api/docs be provided by swaggest, with / being passed on to a http.FileServer, but using chi.Mount() to relocate swaggest from / to /api/ causes the swgui to 404 - but the actual REST connectors work just fine.
My code looks something like this (trimmed here for brevity):
funcmain() {
// setup REST interface with OpenAPI documentations:=web.DefaultService()
s.OpenAPI.Info.Title="..."s.OpenAPI.Info.WithDescription("...")
s.OpenAPI.Info.Version="v0.0.1"s.Get("/item/{id}", getItemByID())
// etc...s.Docs("/docs", v4emb.New)
// static html/css/js files served from embedded FSuiFS:=webui.StaticFS()
// top-level routerr:=chi.NewRouter()
r.Mount("/api/v1", s) // relocate swaggest to /api/v1/...r.Mount("/", http.FileServer(http.FS(uiFS))) // provide static files at /http.ListenAndServe("localhost:8080", r)
}
My problem here is that I have two different handlers (swaggest & http.FileServer) and chi only allows one to be mounted on "/", so I can't just use s.Get("/api/v1/item/{id}",...) because then I can't have the html files at "/"
If anyone has any working examples of having swaggest play nicely with other sub-routers, I'd be most interested.
by the way, I tried Mounting the FileServer on "/static", but that also didn't work. I'm thinking this may be an issue with chi :-/
Thanks in advance
The text was updated successfully, but these errors were encountered:
I tried to use swaggest in my project today and I can't get the swaggest URL's to play nice with static files.
My goal was to have
/api/...
and/api/docs
be provided by swaggest, with / being passed on to ahttp.FileServer
, but usingchi.Mount()
to relocate swaggest from/
to/api/
causes the swgui to 404 - but the actual REST connectors work just fine.My code looks something like this (trimmed here for brevity):
My problem here is that I have two different handlers (swaggest &
http.FileServer
) and chi only allows one to be mounted on "/", so I can't just uses.Get("/api/v1/item/{id}",...)
because then I can't have the html files at "/"If anyone has any working examples of having swaggest play nicely with other sub-routers, I'd be most interested.
by the way, I tried Mounting the FileServer on "/static", but that also didn't work. I'm thinking this may be an issue with chi :-/
Thanks in advance
The text was updated successfully, but these errors were encountered: