mirror of https://github.com/gofiber/fiber.git
Update middlewares
parent
ef1b7d7448
commit
5881d18c51
|
@ -3,8 +3,12 @@ package middleware
|
||||||
import "github.com/gofiber/fiber"
|
import "github.com/gofiber/fiber"
|
||||||
|
|
||||||
// Cors : Enable cross-origin resource sharing (CORS) with various options.
|
// Cors : Enable cross-origin resource sharing (CORS) with various options.
|
||||||
func Cors(c *fiber.Ctx, d string) {
|
func Cors(c *fiber.Ctx, origin ...string) {
|
||||||
c.Set("Access-Control-Allow-Origin", d) // Set d to "*" for allow all domains
|
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.Set("Access-Control-Allow-Headers", "X-Requested-With")
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@ import (
|
||||||
|
|
||||||
// Helmet : Helps secure your apps by setting various HTTP headers.
|
// Helmet : Helps secure your apps by setting various HTTP headers.
|
||||||
func Helmet(c *fiber.Ctx) {
|
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()
|
c.Next()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue