mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-23 15:31:26 +00:00
Merge pull request #88 from notzippy/server-engine
Revamped engine to reduce the interface size.
This commit is contained in:
@@ -48,12 +48,11 @@ type Harness struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func renderError(iw http.ResponseWriter, ir *http.Request, err error) {
|
func renderError(iw http.ResponseWriter, ir *http.Request, err error) {
|
||||||
r,w := &revel.GORequest{Goheader:&revel.GOHeader{}}, &revel.GOResponse{Goheader:&revel.GOHeader{}}
|
context := revel.NewGOContext(nil)
|
||||||
r.Set(ir)
|
context.Request.SetRequest(ir)
|
||||||
w.Set(iw)
|
context.Response.SetResponse(iw)
|
||||||
req, resp := revel.NewRequest(r), revel.NewResponse(w)
|
c := revel.NewController(context)
|
||||||
c := revel.NewController(req, resp)
|
c.RenderError(err).Apply(c.Request, c.Response)
|
||||||
c.RenderError(err).Apply(req, resp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeHTTP handles all requests.
|
// ServeHTTP handles all requests.
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ func init() {
|
|||||||
// should probably also have a filter for CSRF
|
// should probably also have a filter for CSRF
|
||||||
// not sure if it can go in the same filter or not
|
// not sure if it can go in the same filter or not
|
||||||
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
|
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
|
||||||
c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
|
c.Response.SetHeader("X-Frame-Options", "SAMEORIGIN")
|
||||||
c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
|
c.Response.SetHeader("X-XSS-Protection", "1; mode=block")
|
||||||
c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")
|
c.Response.SetHeader( "X-Content-Type-Options", "nosniff")
|
||||||
|
|
||||||
fc[0](c, fc[1:]) // Execute the next filter stage.
|
fc[0](c, fc[1:]) // Execute the next filter stage.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user