Add context store

This commit is contained in:
Sdogruyol 2016-07-14 21:56:01 +03:00
parent c9714faab3
commit 09d82ed74b
2 changed files with 40 additions and 1 deletions

View file

@ -2,6 +2,9 @@
# information such as params, content_type e.g
class HTTP::Server
class Context
alias StoreTypes = Nil | String | Int32 | Float64 | Bool
getter store = {} of String => StoreTypes
def params
@request.url_params ||= route_lookup.params
@params ||= Kemal::ParamParser.new(@request)
@ -24,5 +27,13 @@ class HTTP::Server
@session ||= Kemal::Sessions.new(self)
@session.not_nil!
end
def get(name)
@store[name]
end
def set(name, value)
@store[name] = value
end
end
end