github.com/svett/giraffe

Giraffe is a package for Golang that contains an utility functions and struct for work with HTTP


License
MIT
Install
go get github.com/svett/giraffe

Documentation

Giraffe

Giraffe is a package for Golang that contains an utility functions and struct for work with HTTP.

alt text

Installation

$ go get github.com/svett/giraffe

Usage

You can encode an object as JSON in simplified way:

encoder := giraffe.NewHTTPEncoder(responseWriter)
encoder.EncodeJSON(map[string]string{"username": "root", "password": "swordfish"})

It can be encoded with padding as well:

encoder := giraffe.NewHTTPEncoder(responseWriter)
encoder.EncodeJSONP("login", map[string]string{"username": "root", "password": "swordfish"})

A similar operation can be performed for a byte array:

encoder := giraffe.NewHTTPEncoder(responseWriter)
encoder.EncodeData([]byte("gopher))

A plain text can be encoded as well:

encoder := giraffe.NewHTTPEncoder(responseWriter)
encoder.EncodeText("Hello World")

You can render HTML templates:

renderer := giraffe.NewHTMLTemplateRenderer(responseWriter)
renderer.Render("my_template", "Jack")

MIT License