Skip to content

Commit

Permalink
goji: update README for Go 1.7 / context
Browse files Browse the repository at this point in the history
  • Loading branch information
zenazn committed Aug 31, 2016
1 parent 7fb07be commit 1209a0b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ Goji

Goji is a HTTP request multiplexer, similar to [`net/http.ServeMux`][servemux].
It compares incoming requests to a list of registered [Patterns][pattern], and
dispatches to the [Handler][handler] that corresponds to the first matching
dispatches to the [http.Handler][handler] that corresponds to the first matching
Pattern. Goji also supports [Middleware][middleware] (composable shared
functionality applied to every request) and uses the de facto standard
[`x/net/context`][context] to store request-scoped values.
functionality applied to every request) and uses the standard
[`context`][context] package to store request-scoped values.

[servemux]: https://golang.org/pkg/net/http/#ServeMux
[pattern]: https://godoc.org/goji.io#Pattern
[handler]: https://godoc.org/goji.io#Handler
[handler]: https://golang.org/pkg/net/http/#Handler
[middleware]: https://godoc.org/goji.io#Mux.Use
[context]: https://godoc.org/golang.org/x/net/context
[context]: https://golang.org/pkg/context


Quick Start
Expand All @@ -29,17 +29,17 @@ import (

"goji.io"
"goji.io/pat"
"golang.org/x/net/context"
)

func hello(ctx context.Context, w http.ResponseWriter, r *http.Request) {
func hello(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
name := pat.Param(ctx, "name")
fmt.Fprintf(w, "Hello, %s!", name)
}

func main() {
mux := goji.NewMux()
mux.HandleFuncC(pat.Get("/hello/:name"), hello)
mux.HandleFunc(pat.Get("/hello/:name"), hello)

http.ListenAndServe("localhost:8000", mux)
}
Expand Down

0 comments on commit 1209a0b

Please sign in to comment.