Token

    app := erguotou.New()

    app.Get("/", func(ctx *erguotou.Context) {
        jwt := token.NewJwt()
        jwt.User = "dollarkiller"
        jwt.TimeOut = time.Hour * 6

        s, e := token.Token.GeneraJwtToken(jwt)
        if e != nil {
            log.Fatal("token 生成失败")
        }
        ctx.Json(200, map[string]interface{}{
            "token": s,
        })
    })

    app.Get("/user", func(ctx *erguotou.Context) {
        token := ctx.Header("token")
        ctx.String(200, token)
    })

    app.Run(erguotou.SetHost(":8086"))

results matching ""

    No results matching ""