Skip to content

Commit

Permalink
update CREATING_MODULES.md with new features
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeweb committed Jul 19, 2017
1 parent 91f7311 commit 90c7f76
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CREATING_MODULES.md
Expand Up @@ -11,16 +11,18 @@
package main

import (
"net/http"
"log"
"net/http"

"github.com/nuveo/prest/cmd"
"github.com/nuveo/prest/config/router"
"github.com/nuveo/prest/config"
"github.com/nuveo/prest/config/middlewares"
"github.com/nuveo/prest/config/router"
"github.com/urfave/negroni"
)

func main() {
config.Load()
// Reorder middlewares
middlewares.MiddlewareStack = []negroni.Handler{
negroni.Handler(negroni.NewRecovery()),
Expand All @@ -31,6 +33,9 @@ func main() {
// Get pREST app
n := middlewares.GetApp()

// Rgister custom middleware
n.Use(negroni.HandlerFunc(CustomMiddleware))

// Get pPREST router
r := router.Get()

Expand All @@ -43,11 +48,10 @@ func main() {

func Pong(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Pong!"))
return
}

func CustomMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
log.Println("Calling custom middleware")
next(w, r)
}
```
```

0 comments on commit 90c7f76

Please sign in to comment.