gophertype/pkg/controllers/index.go

33 lines
677 B
Go

package controllers
import (
"net/http"
"git.kirsle.net/apps/gophertype/pkg/glue"
"git.kirsle.net/apps/gophertype/pkg/middleware"
"github.com/gorilla/mux"
)
func init() {
glue.Register(glue.Endpoint{
Path: "/admin",
Middleware: []mux.MiddlewareFunc{
middleware.ExampleMiddleware,
},
Handler: func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Admin index"))
},
})
glue.Register(glue.Endpoint{
Path: "/admin/users",
Methods: []string{"GET", "POST"},
Middleware: []mux.MiddlewareFunc{
middleware.ExampleMiddleware,
},
Handler: func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Admin users page"))
},
})
}