Hello, I’m wondering if there are any Kemal users here that wouldn’t mind helping me understand why my usage of add_context_storage_type
(link) is not working.
I have a method that configures my Kemal server with the following lines:
add_context_storage_type TenantModel
add_context_storage_type UserResponse
add_handler AuthMiddleware.new
Inside of AuthMiddleware
, my goal is to have instances of the TenantModel
and UserResponse
that I can pass to routes using env.set "user", user
for example.
Inside of my middleware, I get this error when trying to set a value with my custom type.
api | in src/app/middleware/auth.cr:17: no overload matches 'HTTP::Server::Context#set' with types String, UserResponse
api | Overloads are:
api | - HTTP::Server::Context#set(name : String, value : StoreTypes)
api |
api | env.set "user", user
I am digging through Kemal source code with not much luck. I see what the macro for add_context_storage_type
is doing, but I don’t see why the new type is not included in overloads for #set
.
I did notice that there is a note in the Kemal guide on using add_context_storage_type
that mentions I must define the type first, but I am fairly certain it is being defined before referenced in my middleware.