Cookie

    app := erguotou.New()

    app.Get("/setcookie", func(ctx *erguotou.Context) {
        val := ctx.GetVal("name")

        ctx.SetCookie("name", string(val))

        ctx.Write(200, val)
    })

    app.Get("/getcookie", func(ctx *erguotou.Context) {
        val := ctx.GetVal("name")

        cookie := ctx.GetCookie(string(val))
        log.Println(cookie)

        ctx.Write(200, []byte(cookie))
    })

    err := app.Run(erguotou.SetHost(":8082"), erguotou.SetDebug(false))
    if err != nil {
        panic(err)
    }

results matching ""

    No results matching ""