func GetCustomer(rw http.ResponseWriter, r *http.Request, enc encoding.Encoder, params martini.Params, dtx *apicontext.DataContext) string { var err error var c customer.Customer if err = c.GetCustomerIdFromKey(dtx.APIKey); err != nil { apierror.GenerateError("Trouble getting customer ID", err, rw, r) return "" } if err = c.GetCustomer(dtx.APIKey); err != nil { apierror.GenerateError("Trouble getting customer", err, rw, r, http.StatusServiceUnavailable) return "" } lowerKey := strings.ToLower(dtx.APIKey) for i, u := range c.Users { for _, k := range u.Keys { if strings.ToLower(k.Key) == lowerKey { c.Users[i].Current = true } } } return encoding.Must(enc.Encode(c)) }