1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-22 23:04:14 +00:00

Merge pull request #9 from Fenny/master

Update middlewares
This commit is contained in:
Fenny 2020-02-03 07:56:02 -05:00 committed by GitHub
commit 5dca060382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()
}