Ejemplo n.º 1
0
func (c *Cors) PreflightHandle(ctx *rocket.Context) {
	//ctx.Header().Add("Access-Control-Allow-Credentials", strconv.FormatBool(c.config.AllowCredentials))
	//ctx.Header().Add("Access-Control-Allow-Origin", c.config.AllowOrigin)
	//ctx.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
	//Access-Control-Allow-Methods
	ctx.Header().Add("Access-Control-Allow-Methods", strings.Join(c.config.AllowMethods, ", "))
	ctx.Header().Add("Access-Control-Allow-Headers", strings.Join(c.config.AllowHeaders, ", "))
	c.next(ctx)
}
Ejemplo n.º 2
0
func (c *Cors) SimpleHandle(ctx *rocket.Context) {
	ctx.Header().Add("Access-Control-Allow-Credentials", strconv.FormatBool(c.config.AllowCredentials))
	ctx.Header().Add("Access-Control-Allow-Origin", c.config.AllowOrigin)

	if c.config.AllowMethods != nil {
		ctx.Header().Add("Access-Control-Allow-Methods", strings.Join(c.config.AllowMethods, ", "))
	}

	if c.config.AllowHeaders != nil {
		ctx.Header().Add("Access-Control-Allow-Headers", strings.Join(c.config.AllowHeaders, ", "))
	}
	//Access-Control-Allow-Methods
	c.next(ctx)
}