mirror of
https://github.com/kataras/iris.git
synced 2026-01-11 05:55:57 +00:00
20 days of unstoppable work. Waiting fo go 1.8, I didn't finish yet, some touches remains.
Former-commit-id: ed84f99c89f43fe5e980a8e6d0ee22c186f0e1b9
This commit is contained in:
19
adaptors/cors/LICENSE
Normal file
19
adaptors/cors/LICENSE
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Olivier Poitrey <rs@dailymotion.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
33
adaptors/cors/cors.go
Normal file
33
adaptors/cors/cors.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package cors
|
||||
|
||||
// +------------------------------------------------------------+
|
||||
// | Cors wrapper usage |
|
||||
// +------------------------------------------------------------+
|
||||
//
|
||||
// import "github.com/kataras/iris/adaptors/cors"
|
||||
//
|
||||
// app := iris.New()
|
||||
// app.Adapt(cors.New(cors.Options{})))
|
||||
|
||||
import (
|
||||
"github.com/rs/cors"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
)
|
||||
|
||||
// Options is a configuration container to setup the CORS.
|
||||
type Options cors.Options
|
||||
|
||||
// New returns a new cors router wrapper policy
|
||||
// with the provided options.
|
||||
//
|
||||
// create a new cors middleware, pass its options (casted)
|
||||
// and pass the .ServeHTTP(w,r,next(http.HandlerFunc)) as the wrapper
|
||||
// for the whole iris' Router
|
||||
//
|
||||
// Unlike the cors middleware, this wrapper wraps the entirely router,
|
||||
// it cannot be registered to specific routes. It works better and all Options are working.
|
||||
func New(opts Options) iris.RouterWrapperPolicy { return cors.New(cors.Options(opts)).ServeHTTP }
|
||||
|
||||
// Default returns a New cors wrapper with the default options
|
||||
// accepting GET and POST requests and allowing all origins.
|
||||
func Default() iris.RouterWrapperPolicy { return New(Options{}) }
|
||||
Reference in New Issue
Block a user