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