servant-websockets
servant-websockets copied to clipboard
WebSocket has fewer instances than Raw
I don't understand the internals yet but it's clear that the WebSocket
type is lacking some instances that Raw
has. When trying to wrap servant-auth
's Auth
combinator around Raw
, things work fine. But if I wrap it around WebSocket
I get a No instance for (HasServer (AddSetCookieApi (AddSetCookieApi WebSocket)) '[CookieSettings, JWTSettings])
.
Thanks for the report! I'm also still pretty inexperienced with the internals of servant. This library was more like an early experiment. But I'll look into it as soon as I have time.
Actually I might be wrong about this. It may be that servant-auth
has specific handling of Raw
. I'll need to see if it is extensible!
So I ran into this issue as well (servant-auth authenticated Websockets not type-checking) and here's what I came up with:
type instance AddSetCookieApi WebSocket = WebSocket
instance AddSetCookies ('S n) (m ()) (m ()) where
addSetCookies _ a = a
I'm currently using:
servant-auth 0.3.1.0
servant-auth-server 0.3.2.0
servant-websockets 1.1.0
At this point I think this needs to stay an orphan as I doubt either servant-auth or servant-websockets will aquire the other as a dependency.
Assuming I'm understanding the problem (and solution) correctly, it may be beneficial to change the associated types for HasServer Websocket m
etc. to something like Connection -> m WebsocketNoResponse
instead of Connection -> m ()
. This way, the orphan instance above won't clobber someone actually trying to return ()
somewhere. In general, I don't think the endpoint really "returns" anything, so a custom datatype might let other combinators work better with this library by making it easier to handle edge cases like this without clobbering another use case.
Any solution to this?
I tried @SamProtas's suggestion, but I get • Overlapping instances for Servant.Auth.Server.Internal.AddSetCookie.AddSetCookies
.
Hello, I can use Servant.Auth
with Raw
. But when I have a server with Servant.Auth
and a Servant.WebSockets
endpoint I get the same error as @dnikolovv. Does anyone manage to solve this or have an idea on how to start?