top

Package render is a package that provides functionality for easily rendering JSON, XML, binary data, and HTML templates.

package main

import (
    "encoding/xml"
    "net/http"

    "github.com/unrolled/render"  // or "gopkg.in/unrolled/render.v1"
)

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]string{"hello": "json"})
    })

    mux.HandleFunc("/jsonp", func(w http.ResponseWriter, req *http.Request) {
        r.JSONP(w, http.StatusOK, "callbackName", map[string]string{"hello": "jsonp"})
    })

    mux.HandleFunc("/xml", func(w http.ResponseWriter, req *http.Request) {
        r.XML(w, http.StatusOK, ExampleXml{One: "hello", Two: "xml"})
    })

    mux.HandleFunc("/html", func(w http.ResponseWriter, req *http.Request) {
        // Assumes you have a template in ./templates called "example.tmpl".
        // $ mkdir -p templates && echo "<h1>Hello HTML world.</h1>" > templates/example.tmpl
        r.HTML(w, http.StatusOK, "example", nil)
    })

    http.ListenAndServe("0.0.0.0:3000", mux)
}

Imported by 402 package(s)

  1. bitbucket.org/huperwebs/webutils/search
  2. github.com/3zcurdia/badger
  3. github.com/3zcurdia/go-web-template
  4. github.com/9uuso/vertigo/render
  5. github.com/AlexKomrakov/fakeApi
  6. github.com/AlexKomrakov/git-stats
  7. github.com/AlexKomrakov/gohub/server
  8. github.com/AlexKomrakov/streams
  9. github.com/Altoros/cf-cassandra-broker/api
  10. github.com/ArturKlajnerok/go-samples/go-in-5-minutes/episode5/handlers
  11. github.com/Attamusc/be-janky
  12. github.com/Attamusc/be-janky/routes
  13. github.com/AvivRubys/roomatemoney
  14. github.com/Bnei-Baruch/mms-file-manager/config
  15. github.com/Bowery/broome
  16. github.com/Bowery/delancey
  17. github.com/Bowery/desktop/client
  18. github.com/Bowery/essex
  19. github.com/Bowery/kenmare
  20. github.com/CirrusMio/streakers
  21. github.com/Comcast/cf-scaler-service
  22. github.com/Comcast/cf-scaler-service/fakes
  23. github.com/DapperDox/dapperdox/render
  24. github.com/ECSTeam/memory-based-autoscaler/service
  25. github.com/ECSTeam/memory-user/service
  26. github.com/EOengineer/Golang-Negroni-App
  27. github.com/FlushCapacitor/flush-capacitor
  28. github.com/Gastrograph/registry-proxy
  29. github.com/GoIncremental/web
  30. github.com/Jackgris/mstock/controllers
  31. github.com/Jackgris/mstock/middleware
  32. github.com/JamesClonk/ducking-ninja
  33. github.com/JesseObrien/dietary/server
  34. github.com/JesseObrien/jesseobrien.ca
  35. github.com/JesseObrien/radar/server
  36. github.com/KevinRandolph/traefik
  37. github.com/KloudKtrl/api-gateway
  38. github.com/KloudKtrl/asset-service/app
  39. github.com/KloudKtrl/auth-service/app
  40. github.com/KloudKtrl/internal/base
  41. github.com/KloudKtrl/upload-prototype
  42. github.com/LeKovr/Negroni-Example
  43. github.com/Lupino/holehub/holehubd
  44. github.com/MustWin/traefik
  45. github.com/Qlean/multistager
  46. github.com/Qlean/silvia/silvia
  47. github.com/Rauwekost/doxbuilder
  48. github.com/Rubyss/roomatemoney
  49. github.com/RyotaKatoh/oreppoid/app/filters
  50. github.com/SeanDolphin/goInternet
  51. github.com/SpectoLabs/twitter-app
  52. github.com/Stantheman/youtube-gif-go
  53. github.com/Thermeon/traefik
  54. github.com/UlricQin/gof
  55. github.com/Xe/xeserv.us
  56. github.com/Zephyyrr/esavods/api
  57. github.com/adamar/Mothership/server
  58. github.com/adamar/Negroni-Example
  59. github.com/ae0000/commandline-sql-to-sql
  60. github.com/ae0000/go-structs-to-php
  61. github.com/agaviria/timecraft/modules/configuration
  62. github.com/albertchan/bijou/app/controllers/web
  63. github.com/albertchan/bijou/app/core
  64. github.com/albrow/5w4g-server
  65. github.com/albrow/5w4g-server/controllers
  66. github.com/albrow/martini-json-recovery
  67. github.com/albrow/negroni-json-recovery
  68. github.com/albrow/peeps-negroni/controllers
  69. github.com/albrow/people/controllers
  70. github.com/albrow/todo-backend
  71. github.com/alebaffa/go-web-app
  72. github.com/alexkomrakov/fakeApi
  73. github.com/alexkomrakov/git-stats
  74. github.com/alexkomrakov/gohub/server
  75. github.com/alexkomrakov/streams
  76. github.com/algassimou/traefik
  77. github.com/alt234/affadmin-go
  78. github.com/alt234/affadmin-go/controllers
  79. github.com/alt234/affadmin/controllers
  80. github.com/altoros/cf-cassandra-broker/api
  81. github.com/andjosh/tallii
  82. github.com/andrisetiawan/playground-go/playground/restful_routes
  83. github.com/andyrees/mediacatalogue
  84. github.com/aries-auto/product-widget
  85. github.com/arnoldcano/teaxdeax/interfaces
  86. github.com/arschles/go-in-5-minutes/episode5/handlers
  87. github.com/asteris-llc/traefik
  88. github.com/asvins/core
  89. github.com/asvins/operations
  90. github.com/asvins/router
  91. github.com/asvins/subscription
  92. github.com/asvins/warehouse
  93. github.com/attamusc/be-janky
  94. github.com/attamusc/be-janky/routes
  95. github.com/augustoroman/handler
  96. github.com/aymerick/kowa/server
  97. github.com/bbuck/graphql-go-handler
  98. github.com/billglover/traefik
  99. github.com/bnoguchi/bloomapi/api
  100. github.com/bowery/broome
  101. github.com/bowery/delancey
  102. github.com/bowery/desktop/client
  103. github.com/bowery/essex
  104. github.com/bowery/kenmare
  105. github.com/briandowns/aion
  106. github.com/briandowns/aion/controllers
  107. github.com/briandowns/raceway
  108. github.com/briandowns/raceway/controllers
  109. github.com/carolove/traefik
  110. github.com/ch3lo/inspector/api
  111. github.com/ch3lo/overlord/api
  112. github.com/chrisprice/reset-fork-to-upstream
  113. github.com/clarkezone/retwis-go
  114. github.com/clee/channon
  115. github.com/clippy-io/clippy-api-go
  116. github.com/cloudflare/service/render
  117. github.com/cloudnativego/backing-catalog/service
  118. github.com/cloudnativego/backing-fulfillment/service
  119. github.com/cloudnativego/drones-cmds/service
  120. github.com/cloudnativego/drones-events/service
  121. github.com/cloudnativego/drones-query/service
  122. github.com/cloudnativego/flux-template/server
  123. github.com/cloudnativego/flux-zombieoutbreak/server
  124. github.com/cloudnativego/gogo-service/service
  125. github.com/cloudnativego/react-zombieoutbreak/server
  126. github.com/cloudnativego/secureservice/server
  127. github.com/cloudnativego/vcap
  128. github.com/cloudnativego/web-application
  129. github.com/cloudnativego/websockets/server
  130. github.com/cloudnativego/wof-commandprocessing/service
  131. github.com/cloudnativego/wof-eventprocessing/service
  132. github.com/cloudnativego/wof-mapservice/service
  133. github.com/cloudnativego/wof-reality/service
  134. github.com/cocap10/traefik
  135. github.com/coffeehc/web/protobuf
  136. github.com/comcast/cf-scaler-service
  137. github.com/comcast/cf-scaler-service/fakes
  138. github.com/companieshouse/swaggerly/render
  139. github.com/containous/traefik
  140. github.com/copperhead/android_ota_manager/controllers
  141. github.com/cuigh/traefik
  142. github.com/curt-labs/carter
  143. github.com/cvvs/traefik
  144. github.com/dahernan/goreddit
  145. github.com/danackerson/ackerson.de-go
  146. github.com/danackerson/baseballgames
  147. github.com/danackerson/fritzUnlock
  148. github.com/danackerson/gotorrents
  149. github.com/demotape/sandbox
  150. github.com/derekpitt/slack-intent-bot
  151. github.com/derekpitt/spotpric.es
  152. github.com/devopsbq/traefik
  153. github.com/dgodd/pulsego
  154. github.com/dhilipkumars/traefik
  155. github.com/djannot/ecs-cf-service-broker
  156. github.com/djannot/ecspics
  157. github.com/djannot/ecsui
  158. github.com/djannot/s3bench2
  159. github.com/djannot/traefik
  160. github.com/djannot/tweetstream
  161. github.com/dnamenon/webshop
  162. github.com/dutok/dutokme-server
  163. github.com/dutok/retwis-go
  164. github.com/ednapiranha/go-gopher-web
  165. github.com/ednapiranha/leaves
  166. github.com/edoardo849/go-rest-api-template
  167. github.com/efigence/go-nagiosapi
  168. github.com/efigence/go-powerdns/webapi
  169. github.com/eisneim/gortfolio/gortfolio/controllers
  170. github.com/ejamesc/goblawg-test/cmd
  171. github.com/ejamesc/goblawg/cmd
  172. github.com/eliezedeck/goweb/http
  173. github.com/ello/streams/api
  174. github.com/emilevauge/traefik
  175. github.com/etcinit/speedbump/negronibump
  176. github.com/ewhal/Store-Framework
  177. github.com/fabioberger/Recall/controllers
  178. github.com/fabioberger/examples/people/server/controllers
  179. github.com/fabioberger/negroni-json-recovery
  180. github.com/fabioberger/recall/controllers
  181. github.com/fmd/hafez
  182. github.com/funnythingz/sandbox-go/negroni
  183. github.com/fzerorubigd/kitchen/middlewares
  184. github.com/gansidui/go-example/go-blog
  185. github.com/garrypolley/mux_trial/response
  186. github.com/gecker/gecker-api-server/rendering
  187. github.com/gecker/gecker-api/rendering
  188. github.com/gecker/gecker-backend/rendering
  189. github.com/geoah/golang-rest-api-server-example/middlewares
  190. github.com/geosoft1/go-in-5-minutes/episode5/handlers
  191. github.com/gernest/mrs
  192. github.com/gilankpam/wancak/web
  193. github.com/go-humble/examples/people/server/controllers
  194. github.com/goincremental/web
  195. github.com/gophergala/not_golang_experts/router
  196. github.com/goware/jsonp/example
  197. github.com/gsempe/diceware/diceware-api
  198. github.com/gsempe/diceware/diceware-server
  199. github.com/gsempe/retwis-go
  200. github.com/gshilin/shidur-go/config
  201. github.com/gunnaraasen/311post
  202. github.com/hachi8833/myapp
  203. github.com/heridev/gophergala_repositories/Sleuth
  204. github.com/hnlq715/luffy
  205. github.com/housinganywhere/handler
  206. github.com/ian-kent/go-webapp/render
  207. github.com/ian-kent/service.go/web/render
  208. github.com/ianwalter/flash/lib
  209. github.com/ianwalter/iris/lib
  210. github.com/ifels/stock-filter
  211. github.com/ikennaokpala/go-trial/controllers
  212. github.com/image-server/image-server/server
  213. github.com/ironcamel/go.atompub
  214. github.com/itpkg/reading/api/cms
  215. github.com/itpkg/reading/api/core
  216. github.com/iyee/casgo/cas
  217. github.com/jackgris/mstock/controllers
  218. github.com/jackgris/mstock/middleware
  219. github.com/jaischeema/panorma
  220. github.com/jamesclonk-io/stdlib/web
  221. github.com/jamesmillerio/YNAWB
  222. github.com/jamesyong/o3erp/go/templating
  223. github.com/jangie/traefik
  224. github.com/jayrox/Vertigo-alice
  225. github.com/jboursiquot/going/del
  226. github.com/jerryclinesmith/whosaidthat/app
  227. github.com/jesseobrien/dietary/server
  228. github.com/jesseobrien/jesseobrien.ca
  229. github.com/jesseobrien/radar/server
  230. github.com/jfyne/accordopartners.com/views
  231. github.com/jllopis/try5/api
  232. github.com/jllopis/try5/cmd/try5d
  233. github.com/jmcarbo/casgo/cas
  234. github.com/johnsto/notroller
  235. github.com/johnwilson/webapp/sys
  236. github.com/jonaswouters/goclerk/modules/setting
  237. github.com/jonaswouters/goclerk/routers
  238. github.com/jonaz/traefik
  239. github.com/keighl/glue-gun/app
  240. github.com/keshavdv/docklet
  241. github.com/keshavdv/docklet/context
  242. github.com/keshavdv/docklet/handlers
  243. github.com/kodydoherty/wlca/backend
  244. github.com/kriox26/go-stuff/exercises
  245. github.com/kucuny/delibird/server
  246. github.com/kyokomi/renkin/example
  247. github.com/kyrillzorin/CS3031_Lab2/server
  248. github.com/lair-framework/api-server/app
  249. github.com/leeprovoost/go-rest-api-template
  250. github.com/lucaspirola/simple-go-api
  251. github.com/luismiramirez/ok-go/config
  252. github.com/maratart/goblog/server
  253. github.com/markbates/buffalo
  254. github.com/markbates/going/del
  255. github.com/martensson/vaban
  256. github.com/mattbostock/leavediary/handler
  257. github.com/mcervco/MiguelCervantesCo/controllers
  258. github.com/mcervco/MiguelCervantesCo/modules/tmpl
  259. github.com/mdlayher/wavepipe/api
  260. github.com/mdlayher/wavepipe/core
  261. github.com/mdlayher/wavepipe/subsonic
  262. github.com/mickelsonm/boomer/api
  263. github.com/mikejihbe/traefik
  264. github.com/mikerjacobi/goji-skeleton/controllers
  265. github.com/mikerjacobi/goji-skeleton/middleware
  266. github.com/miku/convvy
  267. github.com/milkllc/imp
  268. github.com/mix3/go-tenco/tenco
  269. github.com/nathanleclaire/tarzan
  270. github.com/nbcnews/midapi
  271. github.com/neeravkumar/go-nagiosapi
  272. github.com/ninnemana/boomer/api
  273. github.com/ninnemana/dev_group_7_20/demo
  274. github.com/nubunto/streamr
  275. github.com/optick/lens/lib
  276. github.com/oxfeeefeee/appgo/server
  277. github.com/patrickdappollonio/division-lfg/base/helpers/render
  278. github.com/patrickdappollonio/thedivisionlfg/internal/helpers/render
  279. github.com/pelmers/autocompeter
  280. github.com/peterbe/autocompeter
  281. github.com/philipgiuliani/rustplanner
  282. github.com/philipgiuliani/rustplanner/controllers
  283. github.com/piinecone/handler
  284. github.com/pingcap/pd/server/api
  285. github.com/pivotal-pez/haas-broker
  286. github.com/pivotal-pez/haas-broker/handlers/instance
  287. github.com/pivotal-pez/pezinventory/service
  288. github.com/pivotalservices/app-metrics-nozzle/service
  289. github.com/pivotalservices/app-usage-nozzle/service
  290. github.com/pkieltyka/godo-app/lib/ws
  291. github.com/pnegahdar/traefik
  292. github.com/pressly/gohttpware/jsonp/example
  293. github.com/pressly/imgry/server
  294. github.com/purpleworks/delibird/server
  295. github.com/rafax/ebdemo
  296. github.com/ralphking/goboiler/config
  297. github.com/rauwekost/doxbuilder
  298. github.com/richardbowden/autocompeter
  299. github.com/robxu9/kahinah
  300. github.com/robxu9/kahinah/render
  301. github.com/runemadsen/ok-go/config
  302. github.com/rusenask/bikend
  303. github.com/rusenask/overseer
  304. github.com/saj1th/imgry/server
  305. github.com/sample/traefik
  306. github.com/sboyettedh/channon
  307. github.com/seanhagen/adventurelookup
  308. github.com/seanhagen/car-gasoline-tracker
  309. github.com/seasaltio/juice/app
  310. github.com/shantanuraj/bookshelf-api
  311. github.com/shiloa/apidemo/api.v1
  312. github.com/shimpeiws/simple_go_server
  313. github.com/shobhitchittora/Riot_API
  314. github.com/shopetan/fastGo
  315. github.com/shopsmart/autocompeter
  316. github.com/shumipro/meetapp/server/views
  317. github.com/shumipro/tiptap/server/apis
  318. github.com/shumipro/tiptap/server/errors
  319. github.com/shumipro/tiptap/server/views
  320. github.com/shunsukeaihara/sphinx-httpserver
  321. github.com/shunsukeaihara/sphinx-httpserver/utils
  322. github.com/sivel/keyster
  323. github.com/sklise/ameliaandsteve
  324. github.com/smacken/goweb/controllers
  325. github.com/sogko/data-gov-sg-graphql-go
  326. github.com/sogko/gosg-graphql-go-demo/server
  327. github.com/sogko/handler
  328. github.com/sogko/slumber/middlewares/renderer
  329. github.com/solher/zest
  330. github.com/sontags/yumr
  331. github.com/soroushjp/negroni-json-recovery
  332. github.com/soroushjp/peeps-negroni/controllers
  333. github.com/soroushjp/speedbump/negronibump
  334. github.com/srhopkins/aion
  335. github.com/srhopkins/aion/controllers
  336. github.com/stereosteve/octoweb/server
  337. github.com/stinkyfingers/amberinnapp
  338. github.com/stinkyfingers/ariesautomotive
  339. github.com/stinkyfingers/ariesautomotive/seo
  340. github.com/stinkyfingers/burgergeddon
  341. github.com/stinkyfingers/marrykillapp
  342. github.com/swisstxt/netmgmt
  343. github.com/tarvold/madavoo/controllers
  344. github.com/tcw/fullstack/web
  345. github.com/terah/budget-planner/handlers
  346. github.com/thbkrkr/traefik
  347. github.com/theSuess/contiu/handlers
  348. github.com/theSuess/lapseslider
  349. github.com/thebyrd/gifsecrets/example
  350. github.com/thermeon/traefik
  351. github.com/thezelus/meowtrics/server
  352. github.com/thomasmodeneis/vaban
  353. github.com/tommyvicananza/traefik
  354. github.com/tomoasleep/isucon6q/go
  355. github.com/tomsteele/shellsquid
  356. github.com/tomsteele/shellsquid/app
  357. github.com/tomsteele/veil-evasion-api/handlers
  358. github.com/tooda02/traefik
  359. github.com/torfuzx/go-rest-api-template
  360. github.com/travjones/Authex
  361. github.com/travjones/authex
  362. github.com/travjones/cm_app
  363. github.com/travjones/sfs/web
  364. github.com/tristanoneil/badger/routes
  365. github.com/tyndyll/montages/infrastructure
  366. github.com/ulricqin/gof
  367. github.com/unprofession-al/restful-snmp
  368. github.com/unprofession-al/yumr
  369. github.com/untoldone/bloomapi/api
  370. github.com/ustrajunior/minion
  371. github.com/vanng822/go-premailer/cmd
  372. github.com/vanng822/r2router/example
  373. github.com/vanng822/rproxy
  374. github.com/vbehar/openshift-dashboard/web
  375. github.com/vidoss/guithis/app
  376. github.com/vidoss/guithis/context
  377. github.com/viniciusfeitosa/GoInRIO
  378. github.com/viniciusfeitosa/GoInRIO/handlers
  379. github.com/viniciusfeitosa/GoInRio/handlers
  380. github.com/vitalie/gokyll
  381. github.com/vqtran/negroni-seed/app/views
  382. github.com/wanelo/image-server/server
  383. github.com/wantedly/productivity/controllers
  384. github.com/wantedly/risu
  385. github.com/wintersone/SimpleGo
  386. github.com/wricardo/configurator/webserver
  387. github.com/ww24/isucon6-qualify/webapp/go
  388. github.com/xyproto/dashboard
  389. github.com/xyproto/mcbanner/web
  390. github.com/yageek/euroconv
  391. github.com/yageek/gecker-backend/rendering
  392. github.com/yangsibai/emus
  393. github.com/yinshuwei/xvxv/qbactions
  394. github.com/yosukesuzuki/bell-app-review-notify
  395. github.com/yosukesuzuki/t2tapp
  396. github.com/younglucky/t
  397. github.com/younglucky/t-sql
  398. github.com/zephyyrr/esavods/api
  399. github.com/zxchris/swaggerly/render
  400. gopkg.in/etcinit/speedbump.v0/negronibump
  401. gopkg.in/etcinit/speedbump.v1/negronibump
  402. gopkg.in/etcinit/speedbump.v2/negronibump

Imported only in test by 8 package(s)

  1. github.com/Bowery/kenmare/kenmare
  2. github.com/bowery/kenmare/kenmare
  3. github.com/cloudnativego/cfmgo/params
  4. github.com/dnem/paged
  5. github.com/pivotal-pez/cfmgo/params
  6. github.com/pivotal-pez/cfmgo/wrap
  7. github.com/sjkaliski/go-meerkat
  8. github.com/vidoss/guithis/handlers