Skip to content

codeafix/mango

 
 

Repository files navigation

Mango Build Status Coverage Status GoDoc MIT

Mango is 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.

Detailed documentation can be found here.

A Hello World example:

package main

import (
  "net/http" 	

  "github.com/spaceweasel/mango"
)

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

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

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

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

TODOs

  • Add methods to allow custom encoders to be added
  • Add methods to allow custom route parameter validators to be added
  • Add more documentation
  • Add OPTIONS handler for CORS support
  • Add OPTIONS methods to test browser
  • Add more route parameter validators

About

A Go HTTP routing package to simplify web service code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%