{-# OPTIONS_GHC -Wno-orphans #-}

{- | Swagger implementation of 'WG.Cookie' and 'WG.SetCookie' traits.

Swagger 2.0 does not support cookie authentication. So these
implementations are no-ops.
-}
module WebGear.Swagger.Trait.Cookie () where

import WebGear.Core.Request (Request)
import WebGear.Core.Response (Response)
import WebGear.Core.Trait (Get (..), Set (..), Trait, TraitAbsence)
import qualified WebGear.Core.Trait.Cookie as WG
import WebGear.Swagger.Handler (SwaggerHandler (..), nullNode)

instance
  (TraitAbsence (WG.Cookie e name val) Request) =>
  Get (SwaggerHandler m) (WG.Cookie e name val) Request
  where
  {-# INLINE getTrait #-}
  getTrait :: forall (ts :: [*]).
Prerequisite (Cookie e name val) ts Request =>
Cookie e name val
-> SwaggerHandler
     m
     (With Request ts)
     (Either
        (Absence (Cookie e name val) Request)
        (Attribute (Cookie e name val) Request))
getTrait Cookie e name val
WG.Cookie = Tree DocNode
-> SwaggerHandler
     m
     (With Request ts)
     (Either
        (Absence (Cookie e name val) Request)
        (Attribute (Cookie e name val) Request))
forall {k} {k1} {k2} (m :: k) (a :: k1) (b :: k2).
Tree DocNode -> SwaggerHandler m a b
SwaggerHandler Tree DocNode
forall a. Tree a
nullNode

instance
  (Trait (WG.SetCookie e name) Response) =>
  Set (SwaggerHandler m) (WG.SetCookie e name) Response
  where
  {-# INLINE setTrait #-}
  setTrait :: forall (ts :: [*]).
SetCookie e name
-> (With Response ts
    -> Response
    -> Attribute (SetCookie e name) Response
    -> With Response (SetCookie e name : ts))
-> SwaggerHandler
     m
     (With Response ts, Attribute (SetCookie e name) Response)
     (With Response (SetCookie e name : ts))
setTrait SetCookie e name
WG.SetCookie With Response ts
-> Response
-> Attribute (SetCookie e name) Response
-> With Response (SetCookie e name : ts)
_ = Tree DocNode
-> SwaggerHandler
     m
     (With Response ts, Attribute (SetCookie e name) Response)
     (With Response (SetCookie e name : ts))
forall {k} {k1} {k2} (m :: k) (a :: k1) (b :: k2).
Tree DocNode -> SwaggerHandler m a b
SwaggerHandler Tree DocNode
forall a. Tree a
nullNode