mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Add context store
This commit is contained in:
parent
c9714faab3
commit
09d82ed74b
2 changed files with 40 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue