Documentation ¶
Overview ¶
Package goji provides an out-of-box web server with reasonable defaults.
Example:
package main import ( "fmt" "net/http" "github.com/zenazn/goji" "github.com/zenazn/goji/web" ) func hello(c web.C, w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %s!", c.URLParams["name"]) } func main() { goji.Get("/hello/:name", hello) goji.Serve() }
This package exists purely as a convenience to programmers who want to get started as quickly as possible. It draws almost all of its code from goji's subpackages, the most interesting of which is goji/web, and where most of the documentation for the web framework lives.
A side effect of this package's ease-of-use is the fact that it is opinionated. If you don't like (or have outgrown) its opinions, it should be straightforward to use the APIs of goji's subpackages to reimplement things to your liking. Both methods of using this library are equally well supported.
Goji requires Go 1.2 or newer.
Index ¶
- Variables
- func Abandon(middleware web.MiddlewareType) error
- func Connect(pattern web.PatternType, handler web.HandlerType)
- func Delete(pattern web.PatternType, handler web.HandlerType)
- func Get(pattern web.PatternType, handler web.HandlerType)
- func Handle(pattern web.PatternType, handler web.HandlerType)
- func Head(pattern web.PatternType, handler web.HandlerType)
- func Insert(middleware, before web.MiddlewareType) error
- func NotFound(handler web.HandlerType)
- func Options(pattern web.PatternType, handler web.HandlerType)
- func Patch(pattern web.PatternType, handler web.HandlerType)
- func Post(pattern web.PatternType, handler web.HandlerType)
- func Put(pattern web.PatternType, handler web.HandlerType)
- func Serve()
- func ServeListener(listener net.Listener)
- func ServeTLS(config *tls.Config)
- func Trace(pattern web.PatternType, handler web.HandlerType)
- func Use(middleware web.MiddlewareType)
Constants ¶
This section is empty.
Variables ¶
var DefaultMux *web.Mux
The default web.Mux.
Functions ¶
func Abandon ¶
func Abandon(middleware web.MiddlewareType) error
Abandon removes the given middleware from the default Mux's middleware stack. See the documentation for web.Mux.Abandon for more information.
func Connect ¶
func Connect(pattern web.PatternType, handler web.HandlerType)
Connect adds a CONNECT route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Delete ¶
func Delete(pattern web.PatternType, handler web.HandlerType)
Delete adds a DELETE route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Get ¶
func Get(pattern web.PatternType, handler web.HandlerType)
Get adds a GET route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Handle ¶
func Handle(pattern web.PatternType, handler web.HandlerType)
Handle adds a route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Head ¶
func Head(pattern web.PatternType, handler web.HandlerType)
Head adds a HEAD route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Insert ¶
func Insert(middleware, before web.MiddlewareType) error
Insert the given middleware into the default Mux's middleware stack. See the documentation for web.Mux.Insert for more information.
func NotFound ¶
func NotFound(handler web.HandlerType)
NotFound sets the NotFound handler for the default Mux. See the documentation for web.Mux.NotFound for more information.
func Options ¶
func Options(pattern web.PatternType, handler web.HandlerType)
Options adds a OPTIONS route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Patch ¶
func Patch(pattern web.PatternType, handler web.HandlerType)
Patch adds a PATCH route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Post ¶
func Post(pattern web.PatternType, handler web.HandlerType)
Post adds a POST route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Put ¶
func Put(pattern web.PatternType, handler web.HandlerType)
Put adds a PUT route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func ServeListener ¶ added in v1.0.1
Like Serve, but runs Goji on top of an arbitrary net.Listener.
func Trace ¶
func Trace(pattern web.PatternType, handler web.HandlerType)
Trace adds a TRACE route to the default Mux. See the documentation for web.Mux for more information about what types this function accepts.
func Use ¶
func Use(middleware web.MiddlewareType)
Use appends the given middleware to the default Mux's middleware stack. See the documentation for web.Mux.Use for more information.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package bind provides a convenient way to bind to sockets.
|
Package bind provides a convenient way to bind to sockets. |
Command example is a sample application built with Goji.
|
Command example is a sample application built with Goji. |
Package graceful implements graceful shutdown for HTTP servers by closing idle connections after receiving a signal.
|
Package graceful implements graceful shutdown for HTTP servers by closing idle connections after receiving a signal. |
listener
Package listener provides a way to incorporate graceful shutdown to any net.Listener.
|
Package listener provides a way to incorporate graceful shutdown to any net.Listener. |
Package web provides a fast and flexible middleware stack and mux.
|
Package web provides a fast and flexible middleware stack and mux. |
middleware
Package middleware provides several standard middleware implementations.
|
Package middleware provides several standard middleware implementations. |
mutil
Package mutil contains various functions that are helpful when writing http middleware.
|
Package mutil contains various functions that are helpful when writing http middleware. |