add path prefix to server.

This commit is contained in:
Miroslav Šedivý
2023-04-28 22:19:52 +02:00
parent c70c8217de
commit 52b4cbcbdf
2 changed files with 22 additions and 7 deletions

View File

@ -36,6 +36,12 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
MaxAge: 300, // Maximum value not ignored by any of major browsers
}))
if config.PathPrefix != "/" {
router.UseBypass(func(h http.Handler) http.Handler {
return http.StripPrefix(config.PathPrefix, h)
})
}
router.Route("/api", ApiManager.Route)
router.Get("/api/ws", WebSocketManager.Upgrade(func(r *http.Request) bool {