Effect CommunityEC
Effect Community10mo ago
1 reply
Riordan

**Understanding RpcMiddleware's Optional Option vs Custom Context and Middleware**

When would I use RpcMiddleware's optional option vs this sort of thing:
export class MaybeSessionContext extends Context.Tag("MaybeSessionContext")<
  MaybeSessionContext,
  Option.Option<SessionAndUser>
>() {}
export class MaybeAuthMiddleware extends RpcMiddleware.Tag<MaybeAuthMiddleware>()(
  "MaybeAuthMiddleware",
  {
    failure: Schema.Union(AuthQueryError),
    provides: MaybeSessionContext,
  },
) {}


Also: I was expecting to use a resource in the execution of my auth middleware to verify my session cookie but R must be never. Was I attempting to use an anti pattern? Should I just be parsing the cookie in the middleware and then verify in my rpc handler?
Was this page helpful?