{"repo":"unrolled/render","free":true,"listed":false,"github":"https://github.com/unrolled/render","clone":"git clone https://github.com/unrolled/render.git","description":"Go package for easily rendering JSON, XML, binary data, and HTML templates responses.","language":"Go","stars":1997,"topics":["golang","go","html","json","xml","binary","text","jsonp"],"license":"MIT","category":"dev-tools","readme_excerpt":"Render Render is a package that provides functionality for easily rendering JSON, XML, text, binary data, and HTML templates. Usage Render can be used with pretty much any web framework providing you can access the http.ResponseWriter from your handler. The rendering functions simply wraps Go's existing functionality for marshaling and rendering data. - HTML: Uses the html/template package to render HTML templates. - JSON: Uses the encoding/json package to marshal data into a JSON-encoded response. - XML: Uses the encoding/xml package to marshal data into an XML-encoded response. - Binary data: Passes the incoming data straight through to the http.ResponseWriter . - Text: Passes the incoming string straight through to the http.ResponseWriter . go // main.go package main import ( \"encoding/xml\" \"net/http\" \"github.com/unrolled/render\" ) type ExampleXml struct { XMLName xml.Name xml:\"example\" One string xml:\"one,attr\" Two string xml:\"two,attr\" } func main() { r := render.New() mux := http.NewServeMux() mux.HandleFunc(\"/\", func(w http.ResponseWriter, req http.Request) { w.Write([]byte(\"Welcome, visit sub pages now.\")) }) mux.HandleFunc(\"/data\", func(w http.ResponseWriter, req http.Request) { r.Data(w, http.StatusOK, []byte(\"Some binary data here.\")) }) mux.HandleFunc(\"/text\", func(w http.ResponseWriter, req http.Request) { r.Text(w, http.StatusOK, \"Plain text here\") }) mux.HandleFunc(\"/json\", func(w http.ResponseWriter, req http.Request) { r.JSON(w, http.StatusOK, map[string]stri","default_branch":null,"files":null,"tree":[],"storefront":"/r/unrolled","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/unrolled/render/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}