Documentation ¶
Overview ¶
@APIVersion 1.0.0 @Title beego Test API @Description beego has a very cool tools to autogenerate documents for your API @Contact astaxie@gmail.com @TermsOfServiceUrl http://beego.me/ @License Apache 2.0 @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FilterUser = func(ctx *context.Context) { req := ctx.Request requestURI := req.RequestURI method := req.Method if ((method == "GET" && len(requestURI) >= 13 && (requestURI[:13] == "/api/v1/proms" || requestURI[:13] == "/api/v1/rules")) || (method == "POST" && len(requestURI) >= 14 && requestURI[:14] == "/api/v1/alerts")) && ctx.Input.Header("Token") == "96smhbNpRguoJOCEKNrMqQ" { return } if len(requestURI) >= 14 && requestURI[:14] == "/api/v1/logout" { return } username, _ := ctx.Input.Session("username").(string) if username == "" && ctx.Request.RequestURI[:13] != "/api/v1/login" { _ = ctx.Output.JSON(common.Res{Code: -1, Msg: "Unauthorized"}, false, false) } }
验证用户是否合法。 途径为,promes/rules/alerts接口,设置token。 /logout则不检查 其他接口,需要获取上下文的username,如果是空,又不是/login接口,则就是不合法登陆。直接返回json格式相应
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.