示例#1
0
文件: main.go 项目: corestoreio/csms
func (a *app) routeLogin(rtr *ctxrouter.Router) {

	staticClaims := map[string]interface{}{
		"xfoo":  "bar",
		"xtime": time.Now().Unix(),
	}

	rtr.GET("/login", func(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
		ts, _, err := a.jwtSrv.GenerateToken(staticClaims)
		if err != nil {
			return err
		}
		return httputil.NewPrinter(w, r).WriteString(http.StatusOK, ts)
	})
}