fastcors

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2021 License: Unlicense Imports: 7 Imported by: 1

README

Fast CORS

License go.dev Go Report Card

CORS middleware for fasthttp server. This project is under construction and shouldn't be used in production environment yet.

This lib is inspired by rs/cors and AdhityaRamadhanus/fasthttpcors.

To-do

  • Improve documentation
  • Improve tests

License

This project code is in the public domain. See the LICENSE file.

The only exception is the lib/ folder:

  • lib/cors/ contains code from rs/cors and its license.
Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be in the public domain, without any additional terms or conditions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowAll

func AllowAll() func(*Options)

func SetAllowCredentials

func SetAllowCredentials(allowCredentials bool) func(*Options)

func SetAllowOriginFunc

func SetAllowOriginFunc(allowOriginFunc func(origin string) bool) func(*Options)

func SetAllowOriginRequestFunc

func SetAllowOriginRequestFunc(allowOriginRequestFunc func(ctx *fasthttp.RequestCtx, origin string) bool) func(*Options)

func SetAllowedHeaders

func SetAllowedHeaders(allowedHeaders []string) func(*Options)

func SetAllowedMethods

func SetAllowedMethods(allowedMethods []string) func(*Options)

func SetAllowedOrigins

func SetAllowedOrigins(allowedOrigins []string) func(*Options)

func SetDebug

func SetDebug(debug bool) func(*Options)

func SetExposedHeaders

func SetExposedHeaders(exposedHeaders []string) func(*Options)

func SetLogger

func SetLogger(logger Logger) func(*Options)

func SetMaxAge

func SetMaxAge(maxAge int) func(*Options)

Types

type Logger

type Logger interface {
	Printf(string, ...interface{})
}

type Options

type Options struct {
	AllowedOrigins         []string
	AllowOriginFunc        func(origin string) bool
	AllowOriginRequestFunc func(ctx *fasthttp.RequestCtx, origin string) bool
	AllowedMethods         []string
	AllowedHeaders         []string
	ExposedHeaders         []string
	MaxAge                 int
	AllowCredentials       bool
	Debug                  bool
	Logger                 Logger
}

type RequestMiddleware

type RequestMiddleware func(fasthttp.RequestHandler) fasthttp.RequestHandler

func New

func New(opts ...func(*Options)) RequestMiddleware

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL