Support reading / writing cookies in API
Update my API type and handler types to reflect which handlers read and write cookies. TODO: - Actually read from and write to Set-Cookie header - Returning `pure NoContent` breaks my types, so I'm returning `undefined` now
This commit is contained in:
parent
9f70cb2c61
commit
c4a090e558
3 changed files with 59 additions and 28 deletions
10
src/Types.hs
10
src/Types.hs
|
|
@ -14,6 +14,8 @@ import Database.SQLite.Simple.Ok
|
|||
import Database.SQLite.Simple.FromField
|
||||
import Database.SQLite.Simple.ToField
|
||||
import GHC.Generics
|
||||
import Web.Cookie
|
||||
import Servant.API
|
||||
import Crypto.Random.Types (MonadRandom)
|
||||
|
||||
import qualified Crypto.KDF.BCrypt as BC
|
||||
|
|
@ -382,3 +384,11 @@ data LoginAttempt = LoginAttempt
|
|||
|
||||
instance FromRow LoginAttempt where
|
||||
fromRow = LoginAttempt <$> field <*> field
|
||||
|
||||
newtype SessionCookie = SessionCookie Cookies
|
||||
|
||||
instance FromHttpApiData SessionCookie where
|
||||
parseHeader x =
|
||||
x |> parseCookies |> SessionCookie |> pure
|
||||
parseQueryParam x =
|
||||
x |> TE.encodeUtf8 |> parseCookies |> SessionCookie |> pure
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue