Categorygithub.com/gofiber/cors
modulepackage
0.2.2
Repository: https://github.com/gofiber/cors.git
Documentation: pkg.go.dev

# README

CORS

Release Discord Test Security Linter

Install

go get -u github.com/gofiber/fiber
go get -u github.com/gofiber/cors

config

PropertyTypeDescriptionDefault
Filterfunc(*Ctx) boolDefines a function to skip middlewarenil
AllowOrigins[]stringAllowOrigin defines a list of origins that may access the resource.[]string{"*"}
AllowMethods[]stringAllowMethods defines a list methods allowed when accessing the resource. This is used in response to a preflight request.[]string{"GET", "POST", "HEAD", "PUT", "DELETE", "PATCH"}
AllowCredentialsboolAllowCredentials indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials.false
ExposeHeaders[]stringExposeHeaders defines a whitelist headers that clients are allowed to access.[]string{}
MaxAgeintMaxAge indicates how long (in seconds) the results of a preflight request can be cached.0

Example

package main

import (
  "github.com/gofiber/fiber"
  "github.com/gofiber/cors"
)

func main() {
  app := fiber.New()

  app.Use(cors.New())

  app.Get("/", func(c *fiber.Ctx) {
    c.Send("Welcome!")
  }) 

  app.Listen(3000)
}

Test

curl -H "Origin: http://example.com" --verbose http://localhost:3000

# Functions

New ...

# Structs

Config ...