mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-20 14:15:09 +00:00
Added BufferedServerHeader to CompressWriter to prevent header from writing out immediately Reduced object stack to a single controller stack which has the request and response objects already instaniated in it Fixed go engine to match new spec Modified code to make use of the Request object to access the ServerEngine (allows caching of ServerHeader and ResponseWriter) Modified simple stack to add an upper bounds to the number of objects in cache, any more objects then the upper bounds will be left to garbage collect
60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
package app
|
|
|
|
import (
|
|
"github.com/revel/revel"
|
|
)
|
|
|
|
var (
|
|
// AppVersion revel app version (ldflags)
|
|
AppVersion string
|
|
|
|
// BuildTime revel app build-time (ldflags)
|
|
BuildTime string
|
|
)
|
|
|
|
func init() {
|
|
// Filters is the default set of global filters.
|
|
revel.Filters = []revel.Filter{
|
|
revel.PanicFilter, // Recover from panics and display an error page instead.
|
|
revel.RouterFilter, // Use the routing table to select the right Action
|
|
revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
|
|
revel.ParamsFilter, // Parse parameters into Controller.Params.
|
|
revel.SessionFilter, // Restore and write the session cookie.
|
|
revel.FlashFilter, // Restore and write the flash cookie.
|
|
revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie.
|
|
revel.I18nFilter, // Resolve the requested language
|
|
HeaderFilter, // Add some security based headers
|
|
revel.InterceptorFilter, // Run interceptors around the action.
|
|
revel.CompressFilter, // Compress the result.
|
|
revel.ActionInvoker, // Invoke the action.
|
|
}
|
|
|
|
|
|
// register startup functions with OnAppStart
|
|
// revel.DevMode and revel.RunMode only work inside of OnAppStart. See Example Startup Script
|
|
// ( order dependent )
|
|
// revel.OnAppStart(ExampleStartupScript)
|
|
// revel.OnAppStart(InitDB)
|
|
// revel.OnAppStart(FillCache)
|
|
}
|
|
|
|
// HeaderFilter adds common security headers
|
|
// TODO turn this into revel.HeaderFilter
|
|
// should probably also have a filter for CSRF
|
|
// not sure if it can go in the same filter or not
|
|
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
|
|
c.Response.SetHeader("X-Frame-Options", "SAMEORIGIN")
|
|
c.Response.SetHeader("X-XSS-Protection", "1; mode=block")
|
|
c.Response.SetHeader( "X-Content-Type-Options", "nosniff")
|
|
|
|
fc[0](c, fc[1:]) // Execute the next filter stage.
|
|
}
|
|
|
|
//func ExampleStartupScript() {
|
|
// // revel.DevMod and revel.RunMode work here
|
|
// // Use this script to check for dev mode and set dev/prod startup scripts here!
|
|
// if revel.DevMode == true {
|
|
// // Dev mode
|
|
// }
|
|
//}
|