haskell-servant / servant-snap

Snap port of servant-server (WIP)
Other
28 stars 18 forks source link

Add tamper-proof handler monad for strict servant API handling #19

Open imalsogreg opened 6 years ago

imalsogreg commented 6 years ago

In servant-server, it is impossible for a user-defined handler to inspect the request and to mess with the response. Since servant-snap uses any MonadSnap m => m a as the handler monad, we lose this guarantee, making it possible to branch on runtime information in the request and to call functions like writeText that impurely modify the response.

The goal of running in a restrictive monad like servant-server's Handler' is to ensure that all HTTP logic is determined by the type of the API. We should provide that functionality inservant-snap` for users that want this level of safety in their API handlers.

It's not clear how this would interact with Snaplets ability to provide use values (db connections, local state, etc.)