HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
gorilla
context
Go2013–2013
gorilla / context

context

Package gorilla/context is a golang registry for global request variables.

2Distinct people
2Mentions
0Explicit recommenders
432GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Package gorilla/context is a golang registry for global request variables.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 12:54:37 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by day2 dated mentions

Observed mentions: 2013-11-12 04:21:33 UTC to 2013-12-08 23:45:54 UTC.

012013-11-12 00:00:00 UTC to 2013-11-13 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsNov 122013-11-13 00:00:00 UTC to 2013-11-14 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-14 00:00:00 UTC to 2013-11-15 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-15 00:00:00 UTC to 2013-11-16 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-16 00:00:00 UTC to 2013-11-17 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-17 00:00:00 UTC to 2013-11-18 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-18 00:00:00 UTC to 2013-11-19 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-19 00:00:00 UTC to 2013-11-20 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-20 00:00:00 UTC to 2013-11-21 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-21 00:00:00 UTC to 2013-11-22 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-22 00:00:00 UTC to 2013-11-23 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-23 00:00:00 UTC to 2013-11-24 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-24 00:00:00 UTC to 2013-11-25 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-25 00:00:00 UTC to 2013-11-26 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsNov 252013-11-26 00:00:00 UTC to 2013-11-27 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-27 00:00:00 UTC to 2013-11-28 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-28 00:00:00 UTC to 2013-11-29 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-29 00:00:00 UTC to 2013-11-30 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-30 00:00:00 UTC to 2013-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-01 00:00:00 UTC to 2013-12-02 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-02 00:00:00 UTC to 2013-12-03 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-03 00:00:00 UTC to 2013-12-04 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-04 00:00:00 UTC to 2013-12-05 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-05 00:00:00 UTC to 2013-12-06 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-06 00:00:00 UTC to 2013-12-07 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-07 00:00:00 UTC to 2013-12-08 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-08 00:00:00 UTC to 2013-12-09 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsDec 8

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Nov 122013-11-12 00:00:00 UTC2013-11-13 00:00:00 UTC101
Nov 132013-11-13 00:00:00 UTC2013-11-14 00:00:00 UTC000
Nov 142013-11-14 00:00:00 UTC2013-11-15 00:00:00 UTC000
Nov 152013-11-15 00:00:00 UTC2013-11-16 00:00:00 UTC000
Nov 162013-11-16 00:00:00 UTC2013-11-17 00:00:00 UTC000
Nov 172013-11-17 00:00:00 UTC2013-11-18 00:00:00 UTC000
Nov 182013-11-18 00:00:00 UTC2013-11-19 00:00:00 UTC000
Nov 192013-11-19 00:00:00 UTC2013-11-20 00:00:00 UTC000
Nov 202013-11-20 00:00:00 UTC2013-11-21 00:00:00 UTC000
Nov 212013-11-21 00:00:00 UTC2013-11-22 00:00:00 UTC000
Nov 222013-11-22 00:00:00 UTC2013-11-23 00:00:00 UTC000
Nov 232013-11-23 00:00:00 UTC2013-11-24 00:00:00 UTC000
Nov 242013-11-24 00:00:00 UTC2013-11-25 00:00:00 UTC000
Nov 252013-11-25 00:00:00 UTC2013-11-26 00:00:00 UTC000
Nov 262013-11-26 00:00:00 UTC2013-11-27 00:00:00 UTC000
Nov 272013-11-27 00:00:00 UTC2013-11-28 00:00:00 UTC000
Nov 282013-11-28 00:00:00 UTC2013-11-29 00:00:00 UTC000
Nov 292013-11-29 00:00:00 UTC2013-11-30 00:00:00 UTC000
Nov 302013-11-30 00:00:00 UTC2013-12-01 00:00:00 UTC000
Dec 12013-12-01 00:00:00 UTC2013-12-02 00:00:00 UTC000
Dec 22013-12-02 00:00:00 UTC2013-12-03 00:00:00 UTC000
Dec 32013-12-03 00:00:00 UTC2013-12-04 00:00:00 UTC000
Dec 42013-12-04 00:00:00 UTC2013-12-05 00:00:00 UTC000
Dec 52013-12-05 00:00:00 UTC2013-12-06 00:00:00 UTC000
Dec 62013-12-06 00:00:00 UTC2013-12-07 00:00:00 UTC000
Dec 72013-12-07 00:00:00 UTC2013-12-08 00:00:00 UTC000
Dec 82013-12-08 00:00:00 UTC2013-12-09 00:00:00 UTC101

What Hacker News says

2 sources
Actually (https://github.com/gorilla/context/blob/master/context.go): var ( mutex sync.Mutex data = make(map[*http.Request]map[interface{}]interface{}) datat = make(map[*http.Request]int64) ) // Set stores a value for a given key in a given request. func Set(r *http.Request, key, val interface{}) { mutex.Lock() defer mutex.Unlock() if data[r] == nil { data[r] = make(map[interface{}]interface{}) datat[r] = time.Now().Unix() } data[r][key] = val } The map is needed because 'r' is not actually (and cannot be) modified, so for a later handler (for the same request) to access the data it must be stored in this map, so 'Get' can get it back. And the map is global, so you need a mutex. As a side note, my understanding
Read the rest
is that it is not necessarily un-idiomatic to use a mutex in Go, particularly for shared state. See https://code.google.com/p/go-wiki/wiki/MutexOrChannel
In Writing HTTP Middleware in Go
web.go is definitely pretty old/semi-abandoned. I wouldn't recommend Revel to many (it's Play heritage isn't well suited to Go, IMO) but the Gorilla toolkit—a collection of useful packages that extend net/http, rather than a full-blown framework—is exceptional. mux/pat, schema and sessions are all such useful tools and I've been working with them for a couple of months [in my spare time] as I build a web app w/ Go as a non-programmer. Some other solid Go web packages/tools: • beego (https://github.com/astaxie/beego) - a well-maintained, active project if you want to head down the framework route. Closer to Sinatra/Flask than Django/Rails. • "Bones" (https://github.com/peterskeide/bones) - a useful template for an application/some good design patterns • nosurf (https://github.com/justinas/nosurf) - CSRF middleware that plugs into net/http
Read the rest
(and therefore works with gorilla/mux or pat) • gorilla/context (http://github.com/gorilla/context) - request context. Great for passing per-request variables (i.e. CSRF tokens, saved forms, etc) between your middleware and your wrapped handlers. Set up some Get and Set wrappers around your specific keys so you can avoid writing out type assertions every time you want to retrieve the stored object. • go.stripe (https://github.com/drone/go.stripe) - a fairly complete Stripe library. • blackfriday (https://github.com/russross/blackfriday) - Markdown processor. Obviously, frameworks (and ecosystems...) like Flask, Sinatra, Django and Rails have an advantage in that you can get stuff done today: they do a lot for you. And, for many use-cases, performance will never be a problem. Saying that, writing HTTP logic in Go has been surprisingly easy, and the small amount of extra boilerplate you have to write (if you're sans-framework like me) is nice when you realise how darned fast your application is. Being able to deploy a single binary and front-end it with nginx also reduces a ton of complexity. PS: Once I finish this thing off over the Christmas break, I'm hoping to write up a few articles on the bits-and-pieces that took a bit of time to "get right". Also have a minimalist (i.e. wraps HandleFunc, not Handler) CSRF package in the works.
In Web.go – Web applications with Go

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.