19 lines
469 B
Go
19 lines
469 B
Go
package main
|
|
|
|
import "net/http"
|
|
|
|
// dealing with the context path in a simple way
|
|
|
|
type HttpContext struct {
|
|
mux *http.ServeMux
|
|
path string
|
|
}
|
|
|
|
func (context HttpContext) Handle(pattern string, handler http.Handler) {
|
|
context.mux.Handle(context.path+pattern, http.StripPrefix(context.path, handler))
|
|
}
|
|
|
|
func (context HttpContext) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) {
|
|
context.mux.HandleFunc(context.path+pattern, handler)
|
|
}
|