Browse Source

Return map instead of pointer value

As kisielk just [told me](709e005f84 (commitcomment-3636470),) maps can be nil
Pieter Joost van de Sande 13 years ago
committed by Adam Mckaig
parent
commit
b680aaae68
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      context.go
  2. +1
    -1
      context_test.go

+ 2
- 2
context.go View File

@ -49,12 +49,12 @@ func GetOk(r *http.Request, key interface{}) (interface{}, bool) {
}
// GetAll returns all stored values for the request as a map. Nil is returned for invalid requests.
func GetAll(r *http.Request) *map[interface{}]interface{} {
func GetAll(r *http.Request) map[interface{}]interface{} {
mutex.Lock()
defer mutex.Unlock()
if context, ok := data[r]; ok {
return &context
return context
}
return nil
}


+ 1
- 1
context_test.go View File

@ -54,7 +54,7 @@ func TestContext(t *testing.T) {
// GetAll()
values := GetAll(r)
assertEqual(len(*values), 3)
assertEqual(len(values), 3)
// GetAll() for empty request
values = GetAll(emptyR)


Loading…
Cancel
Save