Skip to content
This repository has been archived by the owner on Jan 12, 2020. It is now read-only.
/ cors Public archive

Cors requests support in REST API framework

License

Notifications You must be signed in to change notification settings

go-rs/cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Middleware: CORS Request

Reference

Config

type Config struct {
	Origin        []string
	Methods       []string
	Headers       []string
	ExposeHeaders []string
	Credentials   bool
	MaxAge        time.Duration
}

// Default
var _config = Config{
	Origin:      []string{"*"},
	Methods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"},
	Headers:     []string{"Content-Type"},
	Credentials: false,
	MaxAge:      time.Hour,
}

How to use?

var api rest.API

config := cors.Config{
    Methods: []string{"GET", "POST"},
    Credentials: true,
    MaxAge: 6 * time.Hour,
}

api.Use(cors.Load(config))

About

Cors requests support in REST API framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages