knowyt/server/handler/authmux.go

28 lines
571 B
Go
Raw Normal View History

2021-07-28 20:21:14 +00:00
package handler
import (
"net/http"
)
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 func(http.ResponseWriter, *http.Request)) {
authMux.mux.HandleFunc(pattern, handlerFunc)
}
func (authMux *AuthMux) PublicHandle(pattern string, handler http.Handler) {
authMux.mux.Handle(pattern, handler)
}