api.go 418 B

12345678910111213141516171819202122232425262728
  1. package ss
  2. import (
  3. )
  4. type Handler interface {
  5. Handle(c *Context)
  6. }
  7. // The type is used for custom-one-place implementation
  8. // of handling.
  9. type Func func(*Context)
  10. func (fn Func) Handle(c *Context) {
  11. fn(c)
  12. }
  13. // The wrapper for the standard http.Handler(s).
  14. type Wrap struct {
  15. UseRelUrl bool
  16. HttpHandler
  17. }
  18. func (w Wrap) Handle(c *Context) {
  19. if w.UseRelUrl {
  20. c.R.URL = c.RelUrl
  21. }
  22. w.ServeHTTP(c.W, c.R)
  23. }