コード例 #1
0
ファイル: kitchensink.go プロジェクト: dbrain/soggy
func adminOnly(ctx *soggy.Context, name string) map[string]string {
	if name == "admin" {
		ctx.Next(nil)
		return nil
	}
	return map[string]string{"error": "Not admin"}
}
コード例 #2
0
ファイル: onetouch.go プロジェクト: dbrain/onetouch-commander
func passwordAuthenticate(ctx *soggy.Context) (int, string) {
	if config.Password != "" {
		headers := ctx.Req.Header
		if headers.Get("Authorization") != config.Password {
			return 403, "Invalid password"
		}
	}
	ctx.Next(nil)
	return -1, ""
}
コード例 #3
0
ファイル: kitchensink.go プロジェクト: dbrain/soggy
func (middleware *MiddlewareExample) Execute(ctx *soggy.Context) {
	log.Println("I've hit the custom middleware")
	// Call the next middleware, if this isn't called the request will end
	ctx.Next(nil)
}