app

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AppVersion revel app version (ldflags)
	AppVersion string

	// BuildTime revel app build-time (ldflags)
	BuildTime string
)
View Source
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
	accessHostsConfig := revel.Config.StringDefault("access.hosts", "")
	accessHosts := strings.Split(accessHostsConfig, ",")
	c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
	c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
	c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")

	if inStringArray(c.Request.Host, accessHosts) || accessHostsConfig == "*" {
		protocol := "http://"

		if strings.Contains(c.Request.Proto, "HTTPS") {
			protocol = "https://"
		}

		c.Response.Out.Header().Add(
			"Access-Control-Allow-Origin",
			protocol+c.Request.Host)

		if accessHostsConfig == "*" {
			c.Response.Out.Header().Set("Access-Control-Allow-Origin", "*")
		}

		c.Response.Out.Header().Add("Access-Control-Allow-Methods", "GET, PUT, POST, PATCH, DELETE, OPTIONS")
		c.Response.Out.Header().Add("Access-Control-Allow-Headers", "accept,content-type")
	}

	fc[0](c, fc[1:])
}

HeaderFilter adds common security headers not sure if it can go in the same filter or not

Functions

func ParseJsonBodyFilter

func ParseJsonBodyFilter(c *revel.Controller, fc []revel.Filter)

func RemoveDomainBasePath

func RemoveDomainBasePath(c *revel.Controller, fc []revel.Filter)

RemoveDomainBasePath removes the base path from the app structure so the app thinks its sitting on its own root.

func SetResponseFormat

func SetResponseFormat(c *revel.Controller, fc []revel.Filter)

func ValidateDomainBasePath

func ValidateDomainBasePath(c *revel.Controller, fc []revel.Filter)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL