Skip to content

Commit 791b18a

Browse files
committed
convenience function RequestHandlerFunc
1 parent eedee59 commit 791b18a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

http_request_renderable.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ func (f RequestRenderableFunc) RequestRenderable(r *http.Request) (AsRenderable,
2020
return f(r)
2121
}
2222

23+
func RequestHandlerFunc(r RequestRenderableFunc) http.Handler {
24+
return HTTPHandler{Renderable: r}
25+
}
26+
27+
func RequestHandler(r RequestRenderable) http.Handler {
28+
return HTTPHandler{Renderable: r}
29+
}
30+
2331
// HTTPHandler implements http.Handler for a RequestRenderable.
2432
type HTTPHandler struct {
2533
Renderable RequestRenderable

http_request_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import (
1212
)
1313

1414
func TestRequestBasicHandler(t *testing.T) {
15-
var handler = veun.HTTPHandler{
16-
veun.RequestRenderableFunc(func(r *http.Request) (veun.AsRenderable, error) {
17-
return nil, nil
18-
}),
19-
}
15+
var handler = veun.RequestHandlerFunc(func(r *http.Request) (veun.AsRenderable, error) {
16+
return nil, nil
17+
})
2018

2119
mux := http.NewServeMux()
2220

0 commit comments

Comments
 (0)