{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AppMesh.Types.HttpRouteMatch
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.HttpRouteMatch where

import Amazonka.AppMesh.Types.HttpMethod
import Amazonka.AppMesh.Types.HttpPathMatch
import Amazonka.AppMesh.Types.HttpQueryParameter
import Amazonka.AppMesh.Types.HttpRouteHeader
import Amazonka.AppMesh.Types.HttpScheme
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the requirements for a route to match HTTP
-- requests for a virtual router.
--
-- /See:/ 'newHttpRouteMatch' smart constructor.
data HttpRouteMatch = HttpRouteMatch'
  { -- | The client request path to match on.
    HttpRouteMatch -> Maybe HttpPathMatch
path :: Prelude.Maybe HttpPathMatch,
    -- | Specifies the path to match requests with. This parameter must always
    -- start with @\/@, which by itself matches all requests to the virtual
    -- service name. You can also match for path-based routing of requests. For
    -- example, if your virtual service name is @my-service.local@ and you want
    -- the route to match requests to @my-service.local\/metrics@, your prefix
    -- should be @\/metrics@.
    HttpRouteMatch -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The client request query parameters to match on.
    HttpRouteMatch -> Maybe (NonEmpty HttpQueryParameter)
queryParameters :: Prelude.Maybe (Prelude.NonEmpty HttpQueryParameter),
    -- | The client request headers to match on.
    HttpRouteMatch -> Maybe (NonEmpty HttpRouteHeader)
headers :: Prelude.Maybe (Prelude.NonEmpty HttpRouteHeader),
    -- | The client request method to match on. Specify only one.
    HttpRouteMatch -> Maybe HttpMethod
method :: Prelude.Maybe HttpMethod,
    -- | The client request scheme to match on. Specify only one. Applicable only
    -- for HTTP2 routes.
    HttpRouteMatch -> Maybe HttpScheme
scheme :: Prelude.Maybe HttpScheme
  }
  deriving (HttpRouteMatch -> HttpRouteMatch -> Bool
(HttpRouteMatch -> HttpRouteMatch -> Bool)
-> (HttpRouteMatch -> HttpRouteMatch -> Bool) -> Eq HttpRouteMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpRouteMatch -> HttpRouteMatch -> Bool
$c/= :: HttpRouteMatch -> HttpRouteMatch -> Bool
== :: HttpRouteMatch -> HttpRouteMatch -> Bool
$c== :: HttpRouteMatch -> HttpRouteMatch -> Bool
Prelude.Eq, ReadPrec [HttpRouteMatch]
ReadPrec HttpRouteMatch
Int -> ReadS HttpRouteMatch
ReadS [HttpRouteMatch]
(Int -> ReadS HttpRouteMatch)
-> ReadS [HttpRouteMatch]
-> ReadPrec HttpRouteMatch
-> ReadPrec [HttpRouteMatch]
-> Read HttpRouteMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpRouteMatch]
$creadListPrec :: ReadPrec [HttpRouteMatch]
readPrec :: ReadPrec HttpRouteMatch
$creadPrec :: ReadPrec HttpRouteMatch
readList :: ReadS [HttpRouteMatch]
$creadList :: ReadS [HttpRouteMatch]
readsPrec :: Int -> ReadS HttpRouteMatch
$creadsPrec :: Int -> ReadS HttpRouteMatch
Prelude.Read, Int -> HttpRouteMatch -> ShowS
[HttpRouteMatch] -> ShowS
HttpRouteMatch -> String
(Int -> HttpRouteMatch -> ShowS)
-> (HttpRouteMatch -> String)
-> ([HttpRouteMatch] -> ShowS)
-> Show HttpRouteMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpRouteMatch] -> ShowS
$cshowList :: [HttpRouteMatch] -> ShowS
show :: HttpRouteMatch -> String
$cshow :: HttpRouteMatch -> String
showsPrec :: Int -> HttpRouteMatch -> ShowS
$cshowsPrec :: Int -> HttpRouteMatch -> ShowS
Prelude.Show, (forall x. HttpRouteMatch -> Rep HttpRouteMatch x)
-> (forall x. Rep HttpRouteMatch x -> HttpRouteMatch)
-> Generic HttpRouteMatch
forall x. Rep HttpRouteMatch x -> HttpRouteMatch
forall x. HttpRouteMatch -> Rep HttpRouteMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpRouteMatch x -> HttpRouteMatch
$cfrom :: forall x. HttpRouteMatch -> Rep HttpRouteMatch x
Prelude.Generic)

-- |
-- Create a value of 'HttpRouteMatch' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'path', 'httpRouteMatch_path' - The client request path to match on.
--
-- 'prefix', 'httpRouteMatch_prefix' - Specifies the path to match requests with. This parameter must always
-- start with @\/@, which by itself matches all requests to the virtual
-- service name. You can also match for path-based routing of requests. For
-- example, if your virtual service name is @my-service.local@ and you want
-- the route to match requests to @my-service.local\/metrics@, your prefix
-- should be @\/metrics@.
--
-- 'queryParameters', 'httpRouteMatch_queryParameters' - The client request query parameters to match on.
--
-- 'headers', 'httpRouteMatch_headers' - The client request headers to match on.
--
-- 'method', 'httpRouteMatch_method' - The client request method to match on. Specify only one.
--
-- 'scheme', 'httpRouteMatch_scheme' - The client request scheme to match on. Specify only one. Applicable only
-- for HTTP2 routes.
newHttpRouteMatch ::
  HttpRouteMatch
newHttpRouteMatch :: HttpRouteMatch
newHttpRouteMatch =
  HttpRouteMatch' :: Maybe HttpPathMatch
-> Maybe Text
-> Maybe (NonEmpty HttpQueryParameter)
-> Maybe (NonEmpty HttpRouteHeader)
-> Maybe HttpMethod
-> Maybe HttpScheme
-> HttpRouteMatch
HttpRouteMatch'
    { $sel:path:HttpRouteMatch' :: Maybe HttpPathMatch
path = Maybe HttpPathMatch
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:HttpRouteMatch' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:queryParameters:HttpRouteMatch' :: Maybe (NonEmpty HttpQueryParameter)
queryParameters = Maybe (NonEmpty HttpQueryParameter)
forall a. Maybe a
Prelude.Nothing,
      $sel:headers:HttpRouteMatch' :: Maybe (NonEmpty HttpRouteHeader)
headers = Maybe (NonEmpty HttpRouteHeader)
forall a. Maybe a
Prelude.Nothing,
      $sel:method:HttpRouteMatch' :: Maybe HttpMethod
method = Maybe HttpMethod
forall a. Maybe a
Prelude.Nothing,
      $sel:scheme:HttpRouteMatch' :: Maybe HttpScheme
scheme = Maybe HttpScheme
forall a. Maybe a
Prelude.Nothing
    }

-- | The client request path to match on.
httpRouteMatch_path :: Lens.Lens' HttpRouteMatch (Prelude.Maybe HttpPathMatch)
httpRouteMatch_path :: (Maybe HttpPathMatch -> f (Maybe HttpPathMatch))
-> HttpRouteMatch -> f HttpRouteMatch
httpRouteMatch_path = (HttpRouteMatch -> Maybe HttpPathMatch)
-> (HttpRouteMatch -> Maybe HttpPathMatch -> HttpRouteMatch)
-> Lens
     HttpRouteMatch
     HttpRouteMatch
     (Maybe HttpPathMatch)
     (Maybe HttpPathMatch)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRouteMatch' {Maybe HttpPathMatch
path :: Maybe HttpPathMatch
$sel:path:HttpRouteMatch' :: HttpRouteMatch -> Maybe HttpPathMatch
path} -> Maybe HttpPathMatch
path) (\s :: HttpRouteMatch
s@HttpRouteMatch' {} Maybe HttpPathMatch
a -> HttpRouteMatch
s {$sel:path:HttpRouteMatch' :: Maybe HttpPathMatch
path = Maybe HttpPathMatch
a} :: HttpRouteMatch)

-- | Specifies the path to match requests with. This parameter must always
-- start with @\/@, which by itself matches all requests to the virtual
-- service name. You can also match for path-based routing of requests. For
-- example, if your virtual service name is @my-service.local@ and you want
-- the route to match requests to @my-service.local\/metrics@, your prefix
-- should be @\/metrics@.
httpRouteMatch_prefix :: Lens.Lens' HttpRouteMatch (Prelude.Maybe Prelude.Text)
httpRouteMatch_prefix :: (Maybe Text -> f (Maybe Text))
-> HttpRouteMatch -> f HttpRouteMatch
httpRouteMatch_prefix = (HttpRouteMatch -> Maybe Text)
-> (HttpRouteMatch -> Maybe Text -> HttpRouteMatch)
-> Lens HttpRouteMatch HttpRouteMatch (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRouteMatch' {Maybe Text
prefix :: Maybe Text
$sel:prefix:HttpRouteMatch' :: HttpRouteMatch -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: HttpRouteMatch
s@HttpRouteMatch' {} Maybe Text
a -> HttpRouteMatch
s {$sel:prefix:HttpRouteMatch' :: Maybe Text
prefix = Maybe Text
a} :: HttpRouteMatch)

-- | The client request query parameters to match on.
httpRouteMatch_queryParameters :: Lens.Lens' HttpRouteMatch (Prelude.Maybe (Prelude.NonEmpty HttpQueryParameter))
httpRouteMatch_queryParameters :: (Maybe (NonEmpty HttpQueryParameter)
 -> f (Maybe (NonEmpty HttpQueryParameter)))
-> HttpRouteMatch -> f HttpRouteMatch
httpRouteMatch_queryParameters = (HttpRouteMatch -> Maybe (NonEmpty HttpQueryParameter))
-> (HttpRouteMatch
    -> Maybe (NonEmpty HttpQueryParameter) -> HttpRouteMatch)
-> Lens
     HttpRouteMatch
     HttpRouteMatch
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRouteMatch' {Maybe (NonEmpty HttpQueryParameter)
queryParameters :: Maybe (NonEmpty HttpQueryParameter)
$sel:queryParameters:HttpRouteMatch' :: HttpRouteMatch -> Maybe (NonEmpty HttpQueryParameter)
queryParameters} -> Maybe (NonEmpty HttpQueryParameter)
queryParameters) (\s :: HttpRouteMatch
s@HttpRouteMatch' {} Maybe (NonEmpty HttpQueryParameter)
a -> HttpRouteMatch
s {$sel:queryParameters:HttpRouteMatch' :: Maybe (NonEmpty HttpQueryParameter)
queryParameters = Maybe (NonEmpty HttpQueryParameter)
a} :: HttpRouteMatch) ((Maybe (NonEmpty HttpQueryParameter)
  -> f (Maybe (NonEmpty HttpQueryParameter)))
 -> HttpRouteMatch -> f HttpRouteMatch)
-> ((Maybe (NonEmpty HttpQueryParameter)
     -> f (Maybe (NonEmpty HttpQueryParameter)))
    -> Maybe (NonEmpty HttpQueryParameter)
    -> f (Maybe (NonEmpty HttpQueryParameter)))
-> (Maybe (NonEmpty HttpQueryParameter)
    -> f (Maybe (NonEmpty HttpQueryParameter)))
-> HttpRouteMatch
-> f HttpRouteMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
-> Iso
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The client request headers to match on.
httpRouteMatch_headers :: Lens.Lens' HttpRouteMatch (Prelude.Maybe (Prelude.NonEmpty HttpRouteHeader))
httpRouteMatch_headers :: (Maybe (NonEmpty HttpRouteHeader)
 -> f (Maybe (NonEmpty HttpRouteHeader)))
-> HttpRouteMatch -> f HttpRouteMatch
httpRouteMatch_headers = (HttpRouteMatch -> Maybe (NonEmpty HttpRouteHeader))
-> (HttpRouteMatch
    -> Maybe (NonEmpty HttpRouteHeader) -> HttpRouteMatch)
-> Lens
     HttpRouteMatch
     HttpRouteMatch
     (Maybe (NonEmpty HttpRouteHeader))
     (Maybe (NonEmpty HttpRouteHeader))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRouteMatch' {Maybe (NonEmpty HttpRouteHeader)
headers :: Maybe (NonEmpty HttpRouteHeader)
$sel:headers:HttpRouteMatch' :: HttpRouteMatch -> Maybe (NonEmpty HttpRouteHeader)
headers} -> Maybe (NonEmpty HttpRouteHeader)
headers) (\s :: HttpRouteMatch
s@HttpRouteMatch' {} Maybe (NonEmpty HttpRouteHeader)
a -> HttpRouteMatch
s {$sel:headers:HttpRouteMatch' :: Maybe (NonEmpty HttpRouteHeader)
headers = Maybe (NonEmpty HttpRouteHeader)
a} :: HttpRouteMatch) ((Maybe (NonEmpty HttpRouteHeader)
  -> f (Maybe (NonEmpty HttpRouteHeader)))
 -> HttpRouteMatch -> f HttpRouteMatch)
-> ((Maybe (NonEmpty HttpRouteHeader)
     -> f (Maybe (NonEmpty HttpRouteHeader)))
    -> Maybe (NonEmpty HttpRouteHeader)
    -> f (Maybe (NonEmpty HttpRouteHeader)))
-> (Maybe (NonEmpty HttpRouteHeader)
    -> f (Maybe (NonEmpty HttpRouteHeader)))
-> HttpRouteMatch
-> f HttpRouteMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty HttpRouteHeader)
  (NonEmpty HttpRouteHeader)
  (NonEmpty HttpRouteHeader)
  (NonEmpty HttpRouteHeader)
-> Iso
     (Maybe (NonEmpty HttpRouteHeader))
     (Maybe (NonEmpty HttpRouteHeader))
     (Maybe (NonEmpty HttpRouteHeader))
     (Maybe (NonEmpty HttpRouteHeader))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty HttpRouteHeader)
  (NonEmpty HttpRouteHeader)
  (NonEmpty HttpRouteHeader)
  (NonEmpty HttpRouteHeader)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The client request method to match on. Specify only one.
httpRouteMatch_method :: Lens.Lens' HttpRouteMatch (Prelude.Maybe HttpMethod)
httpRouteMatch_method :: (Maybe HttpMethod -> f (Maybe HttpMethod))
-> HttpRouteMatch -> f HttpRouteMatch
httpRouteMatch_method = (HttpRouteMatch -> Maybe HttpMethod)
-> (HttpRouteMatch -> Maybe HttpMethod -> HttpRouteMatch)
-> Lens
     HttpRouteMatch HttpRouteMatch (Maybe HttpMethod) (Maybe HttpMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRouteMatch' {Maybe HttpMethod
method :: Maybe HttpMethod
$sel:method:HttpRouteMatch' :: HttpRouteMatch -> Maybe HttpMethod
method} -> Maybe HttpMethod
method) (\s :: HttpRouteMatch
s@HttpRouteMatch' {} Maybe HttpMethod
a -> HttpRouteMatch
s {$sel:method:HttpRouteMatch' :: Maybe HttpMethod
method = Maybe HttpMethod
a} :: HttpRouteMatch)

-- | The client request scheme to match on. Specify only one. Applicable only
-- for HTTP2 routes.
httpRouteMatch_scheme :: Lens.Lens' HttpRouteMatch (Prelude.Maybe HttpScheme)
httpRouteMatch_scheme :: (Maybe HttpScheme -> f (Maybe HttpScheme))
-> HttpRouteMatch -> f HttpRouteMatch
httpRouteMatch_scheme = (HttpRouteMatch -> Maybe HttpScheme)
-> (HttpRouteMatch -> Maybe HttpScheme -> HttpRouteMatch)
-> Lens
     HttpRouteMatch HttpRouteMatch (Maybe HttpScheme) (Maybe HttpScheme)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRouteMatch' {Maybe HttpScheme
scheme :: Maybe HttpScheme
$sel:scheme:HttpRouteMatch' :: HttpRouteMatch -> Maybe HttpScheme
scheme} -> Maybe HttpScheme
scheme) (\s :: HttpRouteMatch
s@HttpRouteMatch' {} Maybe HttpScheme
a -> HttpRouteMatch
s {$sel:scheme:HttpRouteMatch' :: Maybe HttpScheme
scheme = Maybe HttpScheme
a} :: HttpRouteMatch)

instance Core.FromJSON HttpRouteMatch where
  parseJSON :: Value -> Parser HttpRouteMatch
parseJSON =
    String
-> (Object -> Parser HttpRouteMatch)
-> Value
-> Parser HttpRouteMatch
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpRouteMatch"
      ( \Object
x ->
          Maybe HttpPathMatch
-> Maybe Text
-> Maybe (NonEmpty HttpQueryParameter)
-> Maybe (NonEmpty HttpRouteHeader)
-> Maybe HttpMethod
-> Maybe HttpScheme
-> HttpRouteMatch
HttpRouteMatch'
            (Maybe HttpPathMatch
 -> Maybe Text
 -> Maybe (NonEmpty HttpQueryParameter)
 -> Maybe (NonEmpty HttpRouteHeader)
 -> Maybe HttpMethod
 -> Maybe HttpScheme
 -> HttpRouteMatch)
-> Parser (Maybe HttpPathMatch)
-> Parser
     (Maybe Text
      -> Maybe (NonEmpty HttpQueryParameter)
      -> Maybe (NonEmpty HttpRouteHeader)
      -> Maybe HttpMethod
      -> Maybe HttpScheme
      -> HttpRouteMatch)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe HttpPathMatch)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"path")
            Parser
  (Maybe Text
   -> Maybe (NonEmpty HttpQueryParameter)
   -> Maybe (NonEmpty HttpRouteHeader)
   -> Maybe HttpMethod
   -> Maybe HttpScheme
   -> HttpRouteMatch)
-> Parser (Maybe Text)
-> Parser
     (Maybe (NonEmpty HttpQueryParameter)
      -> Maybe (NonEmpty HttpRouteHeader)
      -> Maybe HttpMethod
      -> Maybe HttpScheme
      -> HttpRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prefix")
            Parser
  (Maybe (NonEmpty HttpQueryParameter)
   -> Maybe (NonEmpty HttpRouteHeader)
   -> Maybe HttpMethod
   -> Maybe HttpScheme
   -> HttpRouteMatch)
-> Parser (Maybe (NonEmpty HttpQueryParameter))
-> Parser
     (Maybe (NonEmpty HttpRouteHeader)
      -> Maybe HttpMethod -> Maybe HttpScheme -> HttpRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty HttpQueryParameter))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"queryParameters")
            Parser
  (Maybe (NonEmpty HttpRouteHeader)
   -> Maybe HttpMethod -> Maybe HttpScheme -> HttpRouteMatch)
-> Parser (Maybe (NonEmpty HttpRouteHeader))
-> Parser (Maybe HttpMethod -> Maybe HttpScheme -> HttpRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty HttpRouteHeader))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"headers")
            Parser (Maybe HttpMethod -> Maybe HttpScheme -> HttpRouteMatch)
-> Parser (Maybe HttpMethod)
-> Parser (Maybe HttpScheme -> HttpRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpMethod)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"method")
            Parser (Maybe HttpScheme -> HttpRouteMatch)
-> Parser (Maybe HttpScheme) -> Parser HttpRouteMatch
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpScheme)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"scheme")
      )

instance Prelude.Hashable HttpRouteMatch

instance Prelude.NFData HttpRouteMatch

instance Core.ToJSON HttpRouteMatch where
  toJSON :: HttpRouteMatch -> Value
toJSON HttpRouteMatch' {Maybe (NonEmpty HttpRouteHeader)
Maybe (NonEmpty HttpQueryParameter)
Maybe Text
Maybe HttpMethod
Maybe HttpPathMatch
Maybe HttpScheme
scheme :: Maybe HttpScheme
method :: Maybe HttpMethod
headers :: Maybe (NonEmpty HttpRouteHeader)
queryParameters :: Maybe (NonEmpty HttpQueryParameter)
prefix :: Maybe Text
path :: Maybe HttpPathMatch
$sel:scheme:HttpRouteMatch' :: HttpRouteMatch -> Maybe HttpScheme
$sel:method:HttpRouteMatch' :: HttpRouteMatch -> Maybe HttpMethod
$sel:headers:HttpRouteMatch' :: HttpRouteMatch -> Maybe (NonEmpty HttpRouteHeader)
$sel:queryParameters:HttpRouteMatch' :: HttpRouteMatch -> Maybe (NonEmpty HttpQueryParameter)
$sel:prefix:HttpRouteMatch' :: HttpRouteMatch -> Maybe Text
$sel:path:HttpRouteMatch' :: HttpRouteMatch -> Maybe HttpPathMatch
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"path" Text -> HttpPathMatch -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpPathMatch -> Pair) -> Maybe HttpPathMatch -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpPathMatch
path,
            (Text
"prefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
prefix,
            (Text
"queryParameters" Text -> NonEmpty HttpQueryParameter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty HttpQueryParameter -> Pair)
-> Maybe (NonEmpty HttpQueryParameter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty HttpQueryParameter)
queryParameters,
            (Text
"headers" Text -> NonEmpty HttpRouteHeader -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty HttpRouteHeader -> Pair)
-> Maybe (NonEmpty HttpRouteHeader) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty HttpRouteHeader)
headers,
            (Text
"method" Text -> HttpMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpMethod -> Pair) -> Maybe HttpMethod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpMethod
method,
            (Text
"scheme" Text -> HttpScheme -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpScheme -> Pair) -> Maybe HttpScheme -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpScheme
scheme
          ]
      )