Skip to content

Commit

Permalink
Gofmt the example usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-uno committed Jul 10, 2014
1 parent e79e4f0 commit 31f4634
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,35 @@ Negroni middleware/handler to enable CORS support.
## Usage

~~~go
package main

import (
"github.com/codegangsta/negroni"
"github.com/hariharan-uno/cors"
"net/http"

"github.com/codegangsta/negroni"
"github.com/hariharan-uno/cors"
)

func main() {
n := negroni.Classic()
n := negroni.Classic()

// CORS for https://*.foo.com origins, allowing:
// - GET and POST methods
// - Origin header
opts := cors.Options{
AllowOrigins: []string{"https://*.foo.com"},
AllowMethods: []string{"GET", "POST"},
AllowHeaders: []string{"Origin"},
}
// CORS for https://*.foo.com origins, allowing:
// - GET and POST methods
// - Origin header
options := cors.Options{
AllowOrigins: []string{"https://*.foo.com"},
AllowMethods: []string{"GET", "POST"},
AllowHeaders: []string{"Origin"},
}

n.Use(negroni.HandlerFunc(opts.Allow))
n.Use(negroni.HandlerFunc(options.Allow))

mux := http.NewServeMux()
// map your routes
mux := http.NewServeMux()
// map your routes

n.UseHandler(mux)
n.UseHandler(mux)

n.Run(":3000")
n.Run(":3000")
}
~~~

Expand Down

0 comments on commit 31f4634

Please sign in to comment.