...

Text file src/goji.io/README.md

Documentation: goji.io

     1Goji
     2====
     3
     4[![GoDoc](https://godoc.org/goji.io?status.svg)](https://godoc.org/goji.io) [![Build Status](https://travis-ci.org/goji/goji.svg?branch=master)](https://travis-ci.org/goji/goji)
     5
     6Goji is a HTTP request multiplexer, similar to [`net/http.ServeMux`][servemux].
     7It compares incoming requests to a list of registered [Patterns][pattern], and
     8dispatches to the [http.Handler][handler] that corresponds to the first matching
     9Pattern. Goji also supports [Middleware][middleware] (composable shared
    10functionality applied to every request) and uses the standard
    11[`context`][context] package to store request-scoped values.
    12
    13[servemux]: https://golang.org/pkg/net/http/#ServeMux
    14[pattern]: https://godoc.org/goji.io#Pattern
    15[handler]: https://golang.org/pkg/net/http/#Handler
    16[middleware]: https://godoc.org/goji.io#Mux.Use
    17[context]: https://golang.org/pkg/context
    18
    19
    20Quick Start
    21-----------
    22
    23```go
    24package main
    25
    26import (
    27        "fmt"
    28        "net/http"
    29
    30        "goji.io"
    31        "goji.io/pat"
    32)
    33
    34func hello(w http.ResponseWriter, r *http.Request) {
    35        name := pat.Param(r, "name")
    36        fmt.Fprintf(w, "Hello, %s!", name)
    37}
    38
    39func main() {
    40        mux := goji.NewMux()
    41        mux.HandleFunc(pat.Get("/hello/:name"), hello)
    42
    43        http.ListenAndServe("localhost:8000", mux)
    44}
    45```
    46
    47Please refer to [Goji's GoDoc Documentation][godoc] for a full API reference.
    48
    49[godoc]: https://godoc.org/goji.io
    50
    51
    52Stability
    53---------
    54
    55Goji's API was recently updated to use the new `net/http` and `context`
    56integration, and is therefore some of its interfaces are in a state of flux. We
    57don't expect any further changes to the API, and expect to be able to announce
    58API stability soon. Goji is suitable for use in production.
    59
    60Prior to Go 1.7, Goji promised API stability with a different API to the one
    61that is offered today. The author broke this promise, and does not take this
    62breach of trust lightly. While stability is obviously extremely important, the
    63author and community have decided to follow the broader Go community in
    64standardizing on the standard library copy of the `context` package.
    65
    66Users of the old API can find that familiar API on the `net-context` branch. The
    67author promises to maintain both the `net-context` branch and `master` for the
    68forseeable future.
    69
    70
    71Community / Contributing
    72------------------------
    73
    74Goji maintains a mailing list, [gojiberries][berries], where you should feel
    75welcome to ask questions about the project (no matter how simple!), to announce
    76projects or libraries built on top of Goji, or to talk about Goji more
    77generally. Goji's author (Carl Jackson) also loves to hear from users directly
    78at his personal email address, which is available on his GitHub profile page.
    79
    80Contributions to Goji are welcome, however please be advised that due to Goji's
    81stability guarantees interface changes are unlikely to be accepted.
    82
    83All interactions in the Goji community will be held to the high standard of the
    84broader Go community's [Code of Conduct][conduct].
    85
    86[berries]: https://groups.google.com/forum/#!forum/gojiberries
    87[conduct]: https://golang.org/conduct

View as plain text