|
|
@@ -8,7 +8,6 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
"html/template"
|
|
|
- "log"
|
|
|
"math"
|
|
|
"net/http"
|
|
|
"path"
|
|
|
@@ -283,18 +282,14 @@ func (c *Context) Set(key string, item interface{}) {
|
|
|
|
|
|
// Returns the value for the given key.
|
|
|
// It panics if the value doesn't exist.
|
|
|
-func (c *Context) Get(key string) interface{} {
|
|
|
- var ok bool
|
|
|
- var item interface{}
|
|
|
+func (c *Context) Get(key string) (interface{}, error) {
|
|
|
if c.Keys != nil {
|
|
|
- item, ok = c.Keys[key]
|
|
|
- } else {
|
|
|
- item, ok = nil, false
|
|
|
- }
|
|
|
- if !ok || item == nil {
|
|
|
- log.Panicf("Key %s doesn't exist", key)
|
|
|
+ item, ok := c.Keys[key]
|
|
|
+ if ok {
|
|
|
+ return item, nil
|
|
|
+ }
|
|
|
}
|
|
|
- return item
|
|
|
+ return nil, errors.New("Key does not exist.")
|
|
|
}
|
|
|
|
|
|
/************************************/
|