-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
42 lines (30 loc) · 886 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package web
import (
"net/http"
)
type ErrorHandlerFunc func(http.ResponseWriter, *http.Request, error)
type Error interface {
Error() string
Status() int
}
type HandlerFunc func(http.ResponseWriter, *http.Request) error
func (f HandlerFunc) TryServeHTTP(w http.ResponseWriter, r *http.Request) error {
return f(w, r)
}
type Handler interface {
TryServeHTTP(http.ResponseWriter, *http.Request) error
}
type RendererFunc func(http.ResponseWriter, *http.Request) error
func (f RendererFunc) Render(w http.ResponseWriter, r *http.Request) error {
return f(w, r)
}
type Renderer interface {
Render(http.ResponseWriter, *http.Request) error
}
type MiddlewareHandlerFunc func(http.Handler) http.Handler
func (f MiddlewareHandlerFunc) Middleware(next http.Handler) http.Handler {
return f(next)
}
type MiddlewareHandler interface {
Middleware(http.Handler) http.Handler
}