A web blog and personal homepage engine written in Go.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
900 B

  1. package controllers
  2. import (
  3. "net/http"
  4. "git.kirsle.net/apps/gophertype/pkg/glue"
  5. "git.kirsle.net/apps/gophertype/pkg/middleware"
  6. "github.com/gorilla/mux"
  7. )
  8. func init() {
  9. glue.Register(glue.Endpoint{
  10. Path: "/about",
  11. Middleware: []mux.MiddlewareFunc{
  12. middleware.ExampleMiddleware,
  13. },
  14. Handler: func(w http.ResponseWriter, r *http.Request) {
  15. w.Write([]byte("About Site"))
  16. },
  17. })
  18. glue.Register(glue.Endpoint{
  19. Path: "/admin",
  20. Middleware: []mux.MiddlewareFunc{
  21. middleware.ExampleMiddleware,
  22. },
  23. Handler: func(w http.ResponseWriter, r *http.Request) {
  24. w.Write([]byte("Admin index"))
  25. },
  26. })
  27. glue.Register(glue.Endpoint{
  28. Path: "/admin/users",
  29. Methods: []string{"GET", "POST"},
  30. Middleware: []mux.MiddlewareFunc{
  31. middleware.ExampleMiddleware,
  32. },
  33. Handler: func(w http.ResponseWriter, r *http.Request) {
  34. w.Write([]byte("Admin users page"))
  35. },
  36. })
  37. }