使用中间件

Erguotou 中间件采用洋葱圈模型设计

使用全局中间件

app := erguotou.New()
app.Use(erguotou.Logger)

在单路由使用

这个中间件通过ctx.Next() 调用下一级

    app.Get("/", func(ctx *erguotou.Context) {
        log.Println("这是一个中间件")
        ctx.Next() // 执行下一级
    }, func(ctx *erguotou.Context) {
        ctx.Json(200, "ok")
    })

在组路由的中间件使用参考在单路由的使用方法

results matching ""

    No results matching ""