Skip to content

Commit

Permalink
Add usage for Gorilla Mux to README.md (#44)
Browse files Browse the repository at this point in the history
* Add Mux usage

* Fix formatting

* hardcode port number
  • Loading branch information
klische authored and unrolled committed Dec 21, 2018
1 parent 4b6b7cf commit 0d6b5bb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,31 @@ func main() {
}
~~~

### [Mux](https://github.com/gorilla/mux)
~~~ go
//main.go
package main

import (
"log"
"net/http"

"github.com/gorilla/mux"
"github.com/unrolled/secure" // or "gopkg.in/unrolled/secure.v1"
)

func main() {
secureMiddleware := secure.New(secure.Options{
FrameDeny: true,
})

r := mux.NewRouter()
r.Use(secureMiddleware.Handler)
http.Handle("/", r)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", 8080), nil))
}
~~~

### [Negroni](https://github.com/codegangsta/negroni)
Note this implementation has a special helper function called `HandlerFuncWithNext`.
~~~ go
Expand Down

0 comments on commit 0d6b5bb

Please sign in to comment.