fasthttp / router

Router implementation for fasthttp
BSD 3-Clause "New" or "Revised" License
465 stars 47 forks source link

Router don't catch panic #71

Closed ad3n closed 1 month ago

ad3n commented 2 months ago
func Index(ctx *fasthttp.RequestCtx) {
    ctx.WriteString("Welcome!")
}

func Hello(ctx *fasthttp.RequestCtx) {
    fmt.Fprintf(ctx, "Hello, %s!\n", ctx.UserValue("name"))
}

func main() {
    r := router.New()
    r.GET("/", Index)
    r.GET("/{name1}/{name3}", Hello)
        r.GET("/{name}/{name3}", Hello)

    log.Fatal(fasthttp.ListenAndServe(":8080", r.Handler))
}

Expected catch panic

savsgio commented 1 month ago

Hi @ad3n,

You must define a PanicHandler, if you want to catch panics.