Documentation
¶
Overview ¶
Package ware is a powerful package for easily create middleware layer in Golang.
For a full guide visit https://github.com/futurespace/ware
package main
import (
"log" "github.com/futurespace/ware"
)
func main() {
w := ware.New()
w.Use(func(c ware.Context, log *log.Logger) {
log.Println("before")
c.Next()
log.Println("after")
})
w.Run()
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
inject.Injector
// Next is an optional function that Middleware Handlers can call to yield the until after
// the other Handlers have been executed. This works really well for any operations that must
// happen after a request
Next()
// Written returns whether or not the response for this context has been written.
Written() bool
// The response instance.
Out(interface{})
}
Context represents a request context. Services can be mapped on the request level from this interface.
type Handler ¶
type Handler interface{}
Handler can be any callable function. Martini attempts to inject services into the handler's argument list. Martini will panic if an argument could not be fullfilled via dependency injection.
type ReturnHandler ¶
ReturnHandler is a service that Martini provides that is called when a route handler returns something. The ReturnHandler is responsible for writing to the ResponseWriter based on the values that are passed into this function.
type Ware ¶
Middleware inject.Injector methods can be invoked to map services on a global level.
func New ¶
func New() *Ware
New creates a base bones Ware instance. Use this method if you want to have full control over the middleware that is used.
func (*Ware) Action ¶
Action sets the handler that will be called after all the middleware has been invoked. This is set to other Ware in a Ware.
