knowyt/server/handler/authmux.go
2021-07-29 21:06:25 +02:00

30 lines
585 B
Go

package handler
import (
"net/http"
)
type HandlerFunc func(http.ResponseWriter, *http.Request)
type AuthMux struct {
mux *http.ServeMux
}
func NewAuthMux() *AuthMux {
return &(AuthMux{
mux: http.NewServeMux(),
})
}
func (authMux *AuthMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
authMux.mux.ServeHTTP(w, r)
}
func (authMux *AuthMux) PublicHandleFunc(pattern string, handlerFunc HandlerFunc) {
authMux.mux.HandleFunc(pattern, handlerFunc)
}
func (authMux *AuthMux) PublicHandle(pattern string, handler http.Handler) {
authMux.mux.Handle(pattern, handler)
}