1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

Update to 8.0.3 | Request logger improvements, error handlers improvements. Read HISTORY.md

Former-commit-id: fb5eca0dc955d8c07fdba35b47068008565dbbd1
This commit is contained in:
kataras
2017-07-16 13:58:10 +03:00
parent 91bb768d4a
commit 56aa3de645
11 changed files with 339 additions and 61 deletions

View File

@@ -22,24 +22,25 @@ func main() {
app.Use(customLogger)
app.Get("/", func(ctx context.Context) {
ctx.Writef("hello")
})
h := func(ctx context.Context) {
ctx.Writef("Hello from %s", ctx.Path())
}
app.Get("/", h)
app.Get("/1", func(ctx context.Context) {
ctx.Writef("hello")
})
app.Get("/1", h)
app.Get("/2", func(ctx context.Context) {
ctx.Writef("hello")
})
app.Get("/2", h)
// log http errors should be done manually
errorLogger := logger.New()
app.OnErrorCode(iris.StatusNotFound, func(ctx context.Context) {
errorLogger(ctx)
ctx.Writef("My Custom 404 error page ")
// http errors have their own handlers, therefore
// registering a middleare should be done manually.
/*
app.OnErrorCode(404 ,customLogger, func(ctx context.Context) {
ctx.Writef("My Custom 404 error page ")
})
*/
// or catch all http errors:
app.OnAnyErrorCode(customLogger, func(ctx context.Context) {
ctx.Writef("My Custom error page")
})
// http://localhost:8080