Documentation ¶
Overview ¶
Package zest contains a lightweight framework based on the codegangsta/cli package allowing clean and easy command line interfaces, the codegangsta/negroni middleware handler, and the solher/syringe injector.
Zest encourages the use of small, well chosen individual dependencies instead of high productivity, full-stack frameworks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Injector = syringe.New()
Injector provide a quick access to an instanciated injector.
Functions ¶
This section is empty.
Types ¶
type APIError ¶ added in v1.0.0
type APIError struct { Status int `json:"status"` Description string `json:"description"` Raw string `json:"raw"` ErrorCode string `json:"errorCode"` }
APIError is the struct defining the format of Zest API errors.
type Logger ¶ added in v1.0.0
type Logger struct { // Logger inherits from log.Logger used to log messages with the Logger middleware. *log.Logger }
Logger is a middleware handler that logs the request as it goes in and the response as it goes out.
func (*Logger) ServeHTTP ¶ added in v1.0.0
func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type Recovery ¶ added in v1.0.0
Recovery is a Negroni inspired middleware handler that recovers from any panic and writes a 500 UNDEFINED_ERROR Zest API error.
func NewRecovery ¶ added in v1.0.0
func NewRecovery() *Recovery
NewRecovery returns a new instance of Recovery
func (*Recovery) ServeHTTP ¶ added in v1.0.0
func (rec *Recovery) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type Render ¶ added in v1.0.0
type Render struct {
// contains filtered or unexported fields
}
Render is a unrolled/render based JSON/XML/HTML renderer, customized to increase the expressiveness of Zest API error rendering.
func NewRender ¶ added in v1.0.0
func NewRender() *Render
NewRender returns a new instance of Render.
type SeqFunc ¶ added in v1.0.0
SeqFunc is the prototype of the functions present in the launch/exit sequences.
type Zest ¶
type Zest struct { Context *cli.Context Server *negroni.Negroni Injector *syringe.Syringe RegisterSequence []SeqFunc InitSequence []SeqFunc ExitSequence []SeqFunc // contains filtered or unexported fields }
Zest is an aggregation of well known and efficient package, also providing a simple launch/exit process to the user.
The launch sequence is divided into three steps: - The register sequence is run, allowing the user to register dependencies into the injector. - The injection is run. - The init sequence is run, allowing the user to properly initialize the freshly built app. Launch and exit sequences are run following the order of the arrays, at each start/stop of the app, thanks to Cli and the tylerb/graceful module.
func Classic ¶
func Classic() *Zest
Classic returns a new instance of Zest, with some default register and init steps: "classicRegister" which registers the default dependencies (Render, Httptreemux) in the injector. "classicInit" which initialize the Httptreemux router and the default middlewares in Negroni.