{-# OPTIONS_GHC -Wno-orphans #-}

-- | OpenApi implementation of 'Method' trait.
module WebGear.OpenApi.Trait.Method where

import WebGear.Core.Request (Request)
import WebGear.Core.Trait (Get (..))
import WebGear.Core.Trait.Method (Method (..))
import WebGear.OpenApi.Handler (DocNode (DocMethod), OpenApiHandler (OpenApiHandler), singletonNode)

instance Get (OpenApiHandler m) Method Request where
  {-# INLINEABLE getTrait #-}
  getTrait :: forall (ts :: [*]).
Method
-> OpenApiHandler
     m
     (Linked ts Request)
     (Either (Absence Method Request) (Attribute Method Request))
getTrait (Method StdMethod
method) = forall {k} {k} {k} (m :: k) (a :: k) (b :: k).
Tree DocNode -> OpenApiHandler m a b
OpenApiHandler forall a b. (a -> b) -> a -> b
$ forall a. a -> Tree a
singletonNode (StdMethod -> DocNode
DocMethod StdMethod
method)