28 lines
419 B
Go
28 lines
419 B
Go
package bond
|
|
|
|
import (
|
|
)
|
|
|
|
type Handler interface {
|
|
Handle(c *Context)
|
|
}
|
|
|
|
// The type is used for custom-one-place implementation
|
|
// of handling.
|
|
type Func func(*Context)
|
|
func (fn Func) Handle(c *Context) {
|
|
fn(c)
|
|
}
|
|
|
|
// The wrapper for the standard http.Handler(s).
|
|
type Wrap struct {
|
|
UseRelUrl bool
|
|
HttpHandler
|
|
}
|
|
func (w Wrap) Handle(c *Context) {
|
|
if w.UseRelUrl {
|
|
c.R.URL = c.RelUrl
|
|
}
|
|
w.ServeHTTP(c.W, c.R)
|
|
}
|
|
|