Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anjmao authored Jul 19, 2019
1 parent 6378588 commit d954e0f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ import (
"github.com/goroute/route"
)

type hello struct {
Title string
type helloResponse struct {
Title string `json:"title"`
}

func main() {
mux := route.NewServeMux()

mux.GET("/", func (c route.Context) error {
return c.JSON(http.StatusOK, &hello{Title:"Hello, World!"})
mux.Use(func(c route.Context, next route.HandlerFunc) error {
log.Println("Hello, Middleware!")
return next(c)
})

mux.GET("/", func(c route.Context) error {
return c.JSON(http.StatusOK, &helloResponse{Title:"Hello, JSON!"})
})

log.Fatal(http.ListenAndServe(":9000", mux))
Expand Down

0 comments on commit d954e0f

Please sign in to comment.