Update middlewares

pull/9/head
Fenny 2020-02-03 13:55:37 +01:00
parent ef1b7d7448
commit 5881d18c51
2 changed files with 7 additions and 3 deletions

View File

@ -3,8 +3,12 @@ package middleware
import "github.com/gofiber/fiber"
// Cors : Enable cross-origin resource sharing (CORS) with various options.
func Cors(c *fiber.Ctx, d string) {
c.Set("Access-Control-Allow-Origin", d) // Set d to "*" for allow all domains
func Cors(c *fiber.Ctx, origin ...string) {
o := "*"
if len(origin) > 0 {
o = origin[0]
}
c.Set("Access-Control-Allow-Origin", o)
c.Set("Access-Control-Allow-Headers", "X-Requested-With")
c.Next()
}

View File

@ -8,6 +8,6 @@ import (
// Helmet : Helps secure your apps by setting various HTTP headers.
func Helmet(c *fiber.Ctx) {
fmt.Println("Helmet is still under development, disable until v1.0.0")
fmt.Println("Helmet is still under development, this middleware does nothing yet.")
c.Next()
}