Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chi-router doesnt seem to work well with swaggerui #2

Closed
talbSE opened this issue Jan 31, 2022 · 6 comments
Closed

chi-router doesnt seem to work well with swaggerui #2

talbSE opened this issue Jan 31, 2022 · 6 comments

Comments

@talbSE
Copy link

talbSE commented Jan 31, 2022

Issue

it looks like when using swaggerui with go-chi router module, the http request fails to find the embedded CSS files and resources.

Screen Shot 2022-01-31 at 9 47 25

Snippet

import github.com/go-chi/chi
r := chi.NewRouter()
r.Handle("/swagger/", http.StripPrefix("/swagger", swaggerui.Handler(spec)))

Additional Info

go 1.17
github.com/go-chi/chi/v5 v5.0.7

@talbSE talbSE changed the title chi-router doesnt work well with this chi-router doesnt seem to work well with swaggerui Jan 31, 2022
@meximonster
Copy link

Hello, the same issue occurs when using gorilla/mux

@goxiaoy
Copy link

goxiaoy commented Mar 30, 2022

@meximonster

router := mux.NewRouter()
router.PathPrefix("/swagger").Handler(http.StripPrefix("/swagger", swaggerui.Handler(spec)))

Works for me

@scohen-examity
Copy link

Same issue here with go-chi -- would love to use this

@luukkemp
Copy link

luukkemp commented Aug 22, 2022

This works for me:

router := chi.NewRouter()
router.Mount("/swagger", http.StripPrefix("/swagger", swaggerui.Handler(spec)))

@flowchartsman
Copy link
Owner

So do we have a good solution here, should I close this issue?

@scohen-examity
Copy link

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants