packages feed

r3x-haskell-sdk-0.1.0.0: src/RubiX/RubixHandler.hs

{-# language OverloadedStrings #-}
{-# language FlexibleContexts #-}
module RubiX.RubixHandler
  ( route
  ) where

import RubiX.Types
import RubiX.RubixRequest
import RubiX.RubixResponse
import Control.Monad

-- Run a handler to match declared routes
route :: ToResponse a => Pattern -> Handler a -> App ()
route routePath handler = do
  doesPathMatch <- matchPaths routePath
  when doesPathMatch $ respondWith handler