Ok, what sounds like a super simple issue. I have a method:
def enforcePermission(permission: Permission): ZIO[SessionContext, PermissionError, Unit]
I’d like to add to my endpoint an attribute:
endpoint.attribute(AttributeKey[Permission], aPermission)
And then, (I think), have an interceptor that picks out my user from the SessionContext from the environment, the permission set in the attribute, and enforce (fail with PermissionError) the permission given the user.
The types are giving me a headache. I think I have it close, but would like some help to make the types work.
I create options with:
ZioHttpServerOptions.default[SessionContext].prependInterceptor {
permissionInterceptor
}
But then I’m not sure how to declare the permissionInterceptor, intelliJ’s helper keeps on insisting I need a double equals arrow (==>) operator that I have no idea what it means, but when I try to create that it doesn’t match what it expects.
What’s really confusing is that this:
def myInterceptor: Interceptor[[_] =>> RIO[SessionContext, _]] = ???
ZioHttpServerOptions.default[SessionContext].prependInterceptor(myInterceptor)
Comes back with
Found: sttp.tapir.server.interceptor.Interceptor[
[_] =>> zio.ZIO[gateway.model.auth.SessionContext, Throwable, ?]]
Required: sttp.tapir.server.interceptor.Interceptor[[_] =>> zio.RIO[gateway.model.auth.SessionContext, _]]
which looks like the same to me!
A simple example would be very, very nice, thanks!