Skip to content

Files

Latest commit

author
Makis Maropoulos
May 12, 2016
6695ca4 · May 12, 2016

History

History
34 lines (22 loc) · 517 Bytes

middleware-recovery.md

File metadata and controls

34 lines (22 loc) · 517 Bytes

Recovery

This is a middleware

Safety recover the server from panic.

recovery.New(...io.Writer)
package main

import (
    "github.com/kataras/iris"
    "github.com/kataras/iris/middleware/recovery"
    "os"
)

func main() {

    iris.Use(recovery.New(os.Stderr)) // optional

    iris.Get("/", func(ctx *iris.Context) {
        ctx.Write("Hi, let's panic")
        panic("Something bad!")
    })

    iris.Listen(":8080")
}