Add Kemal::Context.get? to safely access context storage. Fixes #428

This commit is contained in:
Serdar Dogruyol 2018-01-26 18:30:09 +03:00
parent 17bd3dce37
commit 4034dab952
2 changed files with 98 additions and 58 deletions

View file

@ -10,7 +10,7 @@ class HTTP::Server
macro finished
alias StoreTypes = Union({{ *STORE_MAPPINGS }})
getter store = {} of String => StoreTypes
@store = {} of String => StoreTypes
end
def params
@ -58,5 +58,9 @@ class HTTP::Server
def set(name : String, value : StoreTypes)
@store[name] = value
end
def get?(name : String)
@store[name]?
end
end
end