You have two different problems here. The first one, you are not using a mux.Router, so gorilla/mux has not the opportunity to pre-process your request. In other words, the requests are going directly from http package to your reverse proxies. This issue has an easy fix: r := mux.NewRouter() for...

I found a simple solution... user, ok := session.Values["user"].(*userSchema) if !ok { // user was not of type *userSchema. The assertion failed } This will convert session.Values["user"] from type type interface {} to type *userSchema as part of the assignment....

You might define your own string-based type which holds the hex representation of the value, and implement the bson.Getter and bson.Setter interfaces on it. Gorilla will ignore these interfaces and use the string value, and bson will ignore the string value and use the interface. Something along these lines (untested...

You have a problem with your code because you are storing the user into the app context. With multiple users at the same time, it doesn't work. The context must be related to the request to not be overwrote by other requests. The user must be stored in a request...

How can I load a specific template from a datastore on a per-request basis. //take HTTP for example: resp, err := http.Get("http://mytemplates.com/template1") if err != nil { // handle error } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) templateString := string(body) How can I then send that as a response to...

According Gorilla Websockets Project it is not possible to send pings and pongs using golang.org/x/net/websocket The Gorilla README says something different. It says that the golang.org/x/net package cannot send a ping or receive a pong. It does not say that the package will not send a pong. The golang.org/x/net...

I created a gist ( https://gist.github.com/carbocation/51b55297702c7d30d3ef ) that shows one way to approach this. You need to create a schema.Converter for each of the four types: sql.NullString, sql.NullBool, sql.NullInt64, and sql.NullFloat64. An example for sql.NullString: import "database/sql" import "reflect" func ConvertSQLNullString(value string) reflect.Value { v := sql.NullString{} if err :=...

You can set a custom NotFoundHandler but that will apply to all unmatched routes. If you want a specific response returned you have to define the route explicitly. Example: func main() { r := mux.NewRouter().PathPrefix("/api").Subrouter() // custom not found handler used for unmatched routes var notFound NotFound r.NotFoundHandler = notFound...

Once you call w.WriteHeader(404), the header goes on a wire. So you can't add to it anymore. Best way you can do is to buffer status code and write it at the end of a chain. For example, you can provide your own wrapper for http.ResponseWriter that would re-implement WriteHeader()...

It's not explicitly mentioned in the documentation, but net/http/pprof only registers its handlers with http.DefaultServeMux. From the source: func init() { http.Handle("/debug/pprof/", http.HandlerFunc(Index)) http.Handle("/debug/pprof/cmdline", http.HandlerFunc(Cmdline)) http.Handle("/debug/pprof/profile", http.HandlerFunc(Profile)) http.Handle("/debug/pprof/symbol", http.HandlerFunc(Symbol)) } If you're not using the default mux you just have to register any/all of those you want with whatever mux...

I had the same issue, the problem is the nginx configuration. It defaults to a 1 minute read timeout for proxy_pass: Syntax: proxy_read_timeout time; Default: proxy_read_timeout 60s; Context: http, server, location See http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout In my case I've increased the timeout to 10 hours: proxy_read_timeout 36000s;...

The session data is stored in the client's cookies. So the session you retrieve with store.Get(r, "session-name") is reading that particular client't (request) cookies. You do not need unique names. The name in this case is the name of the cookie so it will be unique to the request.