diff --git a/src/Foundation/Servant.hs b/src/Foundation/Servant.hs index 8ffe716ca..639af858d 100644 --- a/src/Foundation/Servant.hs +++ b/src/Foundation/Servant.hs @@ -36,6 +36,8 @@ import Database.Persist.Sql (transactionUndo) import qualified Data.CaseInsensitive as CI +import GHC.TypeLits (symbolVal) +import Data.Typeable instance ( HasServer sub context , ToJSON restr, FromJSON restr @@ -108,13 +110,14 @@ instance ( HasServer sub context , SBoolI (FoldLenient mods) , FromHttpApiData ciphertext , HasContextEntry context UniWorX + , KnownSymbol sym ) => HasServer (CaptureCryptoID' mods ciphertext sym plaintext :> sub) context where type ServerT (CaptureCryptoID' mods ciphertext sym plaintext :> sub) m = If (FoldLenient mods) (Either String plaintext) plaintext -> ServerT sub m hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy @sub) pc nt . s - route _ context subserver = CaptureRouter . + route _ context subserver = CaptureRouter [hint] . route (Proxy @sub) context . addCapture subserver $ \txt -> case ( sbool :: SBool (FoldLenient mods) , decrypt' <$> parseUrlPiece txt ) of @@ -125,6 +128,7 @@ instance ( HasServer sub context where decrypt' :: CryptoID ciphertext plaintext -> Either Text plaintext decrypt' inp = left tshow . runCatch . runReaderT (decrypt inp) . appCryptoIDKey $ getContextEntry context + hint = CaptureHint (Text.pack $ symbolVal $ Proxy @sym) (typeRep (Proxy :: Proxy sym)) -- from Servant.Server.Internal and modified for our usage type UniWorXContext = Maybe (Route UniWorX) ': Maybe (BearerToken UniWorX) ': IsDryRun ': UniWorX ': '[]