Archived
2
0

add path prefix #196.

This commit is contained in:
Miroslav Šedivý
2022-09-01 18:22:01 +02:00
parent 43fe80c82e
commit 86ab5edf4b
4 changed files with 23 additions and 4 deletions

View File

@ -30,6 +30,12 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server {
router.Use(middleware.RequestLogger(&logformatter{logger}))
router.Use(middleware.Recoverer) // Recover from panics without crashing server
if conf.PathPrefix != "/" {
router.Use(func(h http.Handler) http.Handler {
return http.StripPrefix(conf.PathPrefix, h)
})
}
router.Get("/ws", func(w http.ResponseWriter, r *http.Request) {
err := webSocketHandler.Upgrade(w, r)
if err != nil {