router.go 395 B

123456789101112131415161718192021222324
  1. package router
  2. import (
  3. "errors"
  4. "net/http"
  5. )
  6. var (
  7. ErrInvalidMethod = errors.New("not a valid http method")
  8. ErrInvalidPath = errors.New("path must begin with '/'")
  9. )
  10. type (
  11. Route struct {
  12. Path string
  13. Handler http.HandlerFunc
  14. }
  15. Router interface {
  16. http.Handler
  17. Handle(method string, path string, handler http.Handler) error
  18. SetNotFoundHandler(handler http.Handler)
  19. }
  20. )