albrow / martini-data

Custom data parser middleware for martini. Converts post data (multipart or urlencoded) and query string parameters into a single map[string]string.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

martini-data is a martini middleware wrapper around github.com/albrow/go-data-parser. It automatically parses data from the request body and the url query parameters, provides helper methods for converting data to other types, and supports validations.

Installation and Usage

Install like you would any other package:

go get github.com/albrow/martini-data

Don't forget to import:

import "github.com/albrow/martini-data"

Then add to your martini middleware stack:

m.Use(data.Parser())

Now you can access a Data object in your handler functions:

func MyHandler(data data.Data, res http.ResponseWriter) {
	// ...
}

Note: the Data type comes from the github.com/albrow/go-data-parser package, so you will need to import it as well.

import "github.com/albrow/go-data-parser"

See github.com/albrow/go-data-parser for more information about Data and Validator.

About

Custom data parser middleware for martini. Converts post data (multipart or urlencoded) and query string parameters into a single map[string]string.

License:MIT License


Languages

Language:Go 100.0%