eden

package module
v0.0.0-...-1737cc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2016 License: MIT Imports: 4 Imported by: 0

README

#Eden#

A lightweight minimalist microservice framework for Go.

Eden is built around julienschmidt/httprouter to provide fast high throughput routing and request handling.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Response http.ResponseWriter
	Request  *http.Request
	Params   httprouter.Params
	Data     map[string]interface{}
	Status   int
	// contains filtered or unexported fields
}

Context is the main struct that is used to pass information between different levels of the middleware

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request, p httprouter.Params, mid []Middleware) *Context

NewContext populates a context struct with the given data and returns it

func (*Context) Fail

func (c *Context) Fail(code int, m string)

Fail aborts the context middleware execution and then writes the given code and message to the response.

func (*Context) Next

func (c *Context) Next()

Next allows the context to continue on to the next level of the middleware. Note that each level of the middleware can call c.Next() whenever they would like and then the middleware will go on to finish the chain before completing the code past the c.Next() call

func (*Context) Respond

func (c *Context) Respond(code int, res interface{})

Respond sends the given response in json format

func (*Context) WriteJSON

func (c *Context) WriteJSON(code int, data interface{})

WriteJSON writes the given code and data to the client

type DefaultResponse

type DefaultResponse struct {
	Status string      `json:"status"`
	Data   interface{} `json:"data"`
}

DefaultResponse is a default response object given for convenience to the user if a simplified struct is desired for return

type Middleware

type Middleware func(*Context)

The Middleware type is any function that a *Context

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router represents the eden router

func New

func New() *Router

New returns a new *router to be used to configure the endpoints

func (*Router) DELETE

func (r *Router) DELETE(path string, mid ...Middleware)

DELETE is an alias for router.Register("DELETE", path, middleware)

func (*Router) GET

func (r *Router) GET(path string, mid ...Middleware)

GET is an alias for router.Register("GET", path, middleware)

func (*Router) POST

func (r *Router) POST(path string, mid ...Middleware)

POST is an alias for router.Register("POST", path, middleware)

func (*Router) PUT

func (r *Router) PUT(path string, mid ...Middleware)

PUT is an alias for router.Register("PUT", path, middleware)

func (*Router) Register

func (r *Router) Register(method string, path string, mid ...Middleware)

Register registeres a given method, path, and middleware to the httprouter for handling

func (*Router) Run

func (r *Router) Run(address string) error

Run runs the server listening on the given address

func (*Router) RunTLS

func (r *Router) RunTLS(address string, cert string, key string) error

RunTLS runs a TLS server listening on the given address with the given cert and key

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP calls the httprouter.ServeHTTP and implements router as an http.Handler

func (*Router) Use

func (r *Router) Use(m ...Middleware)

Use appends the given middleware to the router's middleware.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL