package handler import ( "net/http" "sirlab.de/go/knowyt/application" "sirlab.de/go/knowyt/user" ) type HandlerFunc func(http.ResponseWriter, *http.Request) type PrivateHandlerFunc func(*user.User, http.ResponseWriter, *http.Request) type AuthMux struct { mux *http.ServeMux Port int app *application.Application } func NewAuthMux(app *application.Application) *AuthMux { mux := AuthMux{ app: app, mux: http.NewServeMux(), Port: 32039, } http.Handle("/", mux.mux) return &mux } 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) } func (authMux *AuthMux) ListenAndServe() { http.ListenAndServe(":32039", nil) }