1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 05:25:58 +00:00

add example for simple http.Handler wrapper

This commit is contained in:
kataras
2022-06-19 10:01:18 +03:00
parent ef2643b046
commit 9dc356c1d8
4 changed files with 64 additions and 2 deletions

View File

@@ -32,6 +32,17 @@ func FromStd(handler interface{}) context.Handler {
// handlerFunc(w,r, http.HandlerFunc)
//
return FromStdWithNext(h)
case func(http.Handler) http.Handler:
panic(fmt.Errorf(`
Passed handler cannot be converted directly:
- http.Handler(http.Handler)
---------------------------------------------------------------------
Please use the Application.WrapRouter method instead, example code:
app := iris.New()
// ...
app.WrapRouter(func(w http.ResponseWriter, r *http.Request, router http.HandlerFunc) {
httpThirdPartyHandler(router).ServeHTTP(w, r)
})`))
default:
// No valid handler passed
panic(fmt.Errorf(`