ss/api.go

29 lines
419 B
Go
Raw Normal View History

2023-12-07 16:55:23 +03:00
package bond
import (
)
type Handler interface {
Handle(c *Context)
2023-12-07 16:55:23 +03:00
}
// The type is used for custom-one-place implementation
// of handling.
2024-01-03 21:23:03 +03:00
type Func func(*Context)
func (fn Func) Handle(c *Context) {
fn(c)
2023-12-07 16:55:23 +03:00
}
// The wrapper for the standard http.Handler(s).
type Wrap struct {
UseRelUrl bool
HttpHandler
2024-01-03 21:23:03 +03:00
}
func (w Wrap) Handle(c *Context) {
if w.UseRelUrl {
c.R.URL = c.RelUrl
}
w.ServeHTTP(c.W, c.R)
2023-12-07 16:55:23 +03:00
}