All Projects → itsjamie → Gin Cors

itsjamie / Gin Cors

Licence: mit
Cross Origin Resource Sharing middleware for gin-gonic

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Gin Cors

Gzip
💾 Golang gzip middleware for Gin and net/http | Golang gzip中间件,支持Gin和net/http,开箱即用同时可定制
Stars: ✭ 113 (+5.61%)
Mutual labels:  middleware, gin
Flusk
Boilerplate API on how to structure big Flask applications (includes SQLAlchemy, Docker, nginx)
Stars: ✭ 165 (+54.21%)
Mutual labels:  middleware, cors
Gin Swagger
gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
Stars: ✭ 2,001 (+1770.09%)
Mutual labels:  middleware, gin
Go Http Metrics
Go modular http middleware to measure HTTP requests independent of metrics backend (with Prometheus and OpenCensus as backend implementations) and http framework/library
Stars: ✭ 128 (+19.63%)
Mutual labels:  middleware, gin
Gin Stats
Gin's middleware for request stats
Stars: ✭ 24 (-77.57%)
Mutual labels:  middleware, gin
Gin Web
由gin + gorm + jwt + casbin组合实现的RBAC权限管理脚手架Golang版, 搭建完成即可快速、高效投入业务开发
Stars: ✭ 107 (+0%)
Mutual labels:  middleware, gin
Ginrpc
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具
Stars: ✭ 157 (+46.73%)
Mutual labels:  middleware, gin
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Stars: ✭ 53,971 (+50340.19%)
Mutual labels:  middleware, gin
Cors
Node.js CORS middleware
Stars: ✭ 5,252 (+4808.41%)
Mutual labels:  middleware, cors
Meiam.system
.NET 5 / .NET Core 3.1 WebAPI + Vue 2.0 + RBAC 企业级前后端分离权限框架
Stars: ✭ 340 (+217.76%)
Mutual labels:  middleware, cors
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (+148.6%)
Mutual labels:  middleware, cors
Corser
CORS middleware for Node.js
Stars: ✭ 90 (-15.89%)
Mutual labels:  middleware, cors
Gin Glog
Gin middleware to use glog
Stars: ✭ 53 (-50.47%)
Mutual labels:  middleware, gin
Speedbump
A Redis-backed rate limiter in Go
Stars: ✭ 107 (+0%)
Mutual labels:  middleware, gin
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (-9.35%)
Mutual labels:  cors
Redux Favicon
Redux middleware that displays colourful notification badges in the favicon area.
Stars: ✭ 103 (-3.74%)
Mutual labels:  middleware
Ecommerce Nodejs
Ecommerce application back-end codes
Stars: ✭ 97 (-9.35%)
Mutual labels:  cors
Nodefony Starter
Nodefony Starter Node.js Framework
Stars: ✭ 95 (-11.21%)
Mutual labels:  cors
Redux Idle Monitor
A Redux component to schedule events at stages of user idleness across multiple browser tabs.
Stars: ✭ 105 (-1.87%)
Mutual labels:  middleware
Rxcache
A local reactive cache for Java and Android. Now, it supports heap memory、off-heap memory and disk cache.
Stars: ✭ 102 (-4.67%)
Mutual labels:  middleware

CORS for Gin GoDoc Build Status Coverage Status

gin-cors is a middleware written in Go (Golang) specifically for the Gin Framework that implements the Cross Origin Resource Sharing specification from the W3C. Implementing CORS headers enable pages within a modern web browser to consume resources (such as REST APIs) from servers that are on a different domain.

Getting Started

To use this library, add the following code into your Gin router setup:

import "github.com/itsjamie/gin-cors"

// Initialize a new Gin router
router := gin.New()

// Apply the middleware to the router (works with groups too)
router.Use(cors.Middleware(cors.Config{
	Origins:        "*",
	Methods:        "GET, PUT, POST, DELETE",
	RequestHeaders: "Origin, Authorization, Content-Type",
	ExposedHeaders: "",
	MaxAge: 50 * time.Second,
	Credentials: true,
	ValidateHeaders: false,
}))

Setup Options

The middleware can be configured with four options, which match the HTTP headers that it generates:

Parameter Type Details
Origins string A comma delimited list of origins which have access. For example: "http://localhost, http://api.server.com, http://files.server.com"
RequestHeaders string A comma delimited list of allowed HTTP that is passed to the browser in the Access-Control-Allow-Headers header.
ExposeHeaders string A comma delimited list of HTTP headers that should be exposed to the CORS client via the Access-Control-Expose-Headers header.
Methods string A comma delimited list of allowed HTTP methods that is passed to the browser in the Access-Control-Allow-Methods.
MaxAge time.Duration The amount of time a preflight request should be cached, if not specified, the header Access-Control-Max-Age will not be set.
Credentials bool This is passed in the Access-Control-Allow-Credentials header. If true Cookies, HTTP authentication and the client-side SSL certificates will be sent on previous interactions with the origin.
ValidateHeaders bool If false we skip validating the requested headers/methods with the list of allowed ones, and instead just respond with all what we support, it is up to the client implementating CORS to deny the request. This is an optimization allowed by the specification.

CORS Resources

Special Thanks

Special thanks to benpate for providing a foundation to work from.

License

The code is licensed under the MIT License. See LICENSE file for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].