Skip to content

Latest commit

 

History

History
63 lines (49 loc) · 3.49 KB

README.md

File metadata and controls

63 lines (49 loc) · 3.49 KB

Mango Build Status Coverage Status GoDoc MIT

Mango is essentially a routing package designed to simplify the development of web service code in Golang. The Router object implements the standard library's http.Handler interface, so it can be used with the http.ListenAndServe method.

Mango uses a context per request approach which enables simplified handlers, as much of the boiler plate work is done for you. The Context object takes care of tasks such as serialization/deserialization, respecting the Content-Type and Accept headers to ensure responses match the request. You can add your own custom content-type encoders if required.

A radix-tree based routing system enables better response times and greater flexibility in the way routes are structured and added to the system.

Hooks and other mechanisms exist to enable customization in accordance with your specific application, such as authentication, database repository injection.

Mango includes many features to speed up your webservice development, including simple CORS setup, a customizable validation system for your routes and models (with several validators built in), plus an easy to use test browser to enable end-to-end simulation testing.

A Hello World example:

package main

import (
  "net/http" 	

  "github.com/spaceweasel/mango"
)

func main() {
  // get a new router instance
  r := mango.NewRouter()

  // register a GET handler function
  r.Get("/hello", hello)

  // assign the router as the main handler
  http.ListenAndServe(":8080", r)
}

// hello handler function
func hello(c *mango.Context) {
  c.RespondWith("Hello world!")
}

Documentation