Exemple #1
0
		Func: func(ctx foundation.Context) {
			req := ctx.Request()
			foundation.DebugPrintf("Request ClientIP: %s\n", req.ClientIP())
			foundation.DebugPrintf("Request User-Agent: %s\n", req.UserAgent())
			ctx.Operation().Next()
		},
	}
	return mw
}

var CookieSessionMiddleware = func() foundation.Middleware {
	opt := foundation.SessionOptions{
		Secure:   false,
		HttpOnly: false,
	}
	name, secret := config.GetApp().Name, config.GetApp().Secret
	return foundation.CookieSessionMiddleware(opt, name, []byte(secret))
}

var SecureMiddleware = func() foundation.Middleware {
	opt := foundation.SecureOptions{
		ContentTypeNosniff: true,
		BrowserXssFilter:   true,
	}
	return foundation.SecureMiddleware(opt)
}

var ResponseHeaderMiddleware = func() foundation.Middleware {
	return foundation.Middleware{
		Func: func(ctx foundation.Context) {
			resp := ctx.Response()
Exemple #2
0
// TestInit
func TestInit(t *testing.T) {
	assert := assert.New(t)

	assert.NotEqual("", config.GetApp().Name)
}