Skip to content

Commit

Permalink
Instance default for ServerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-k committed Oct 24, 2023
1 parent d7089f6 commit 8c30d45
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
40 changes: 23 additions & 17 deletions mig-wai/mig-wai.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 1.12
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.35.2.
--
Expand All @@ -7,7 +7,9 @@ cabal-version: 1.12
name: mig-wai
version: 0.1.0.0
synopsis: Render mig-servers as wai-applications
description: Please see the README on GitHub at <https://github.com/githubuser/mig-wai#readme>
description:
Please see the README on GitHub at <https://github.com/githubuser/mig-wai#readme>

category: Web
homepage: https://github.com/githubuser/mig-wai#readme
bug-reports: https://github.com/githubuser/mig-wai/issues
Expand All @@ -16,32 +18,36 @@ maintainer: [email protected]
copyright: 2023 Author name here
license: BSD3
build-type: Simple
extra-source-files:
README.md
extra-source-files: README.md

source-repository head
type: git
type: git
location: https://github.com/githubuser/mig-wai

library
exposed-modules:
Mig.Server.Wai
other-modules:
Paths_mig_wai
hs-source-dirs:
src
exposed-modules: Mig.Server.Wai
other-modules: Paths_mig_wai
hs-source-dirs: src
default-extensions:
OverloadedRecordDot
DuplicateRecordFields
OverloadedStrings
LambdaCase
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -Wunused-packages
DuplicateRecordFields
LambdaCase
OverloadedRecordDot
OverloadedStrings

ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wmissing-export-lists
-Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
-Wunused-packages

build-depends:
base >=4.7 && <5
, bytestring
, containers
, data-default
, exceptions
, mig
, text
, wai
default-language: GHC2021

default-language: GHC2021
1 change: 1 addition & 0 deletions mig-wai/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies:
- text
- wai
- exceptions
- data-default

ghc-options:
- -Wall
Expand Down
4 changes: 4 additions & 0 deletions mig-wai/src/Mig/Server/Wai.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Mig.Server.Wai (
import Control.Monad.Catch
import Data.ByteString qualified as B
import Data.ByteString.Lazy qualified as BL
import Data.Default
import Data.Foldable
import Data.IORef
import Data.Map.Strict qualified as Map
Expand All @@ -32,6 +33,9 @@ data ServerConfig = ServerConfig
, findRoute :: FindRouteType
}

instance Default ServerConfig where
def = ServerConfig Nothing Nothing TreeFinder

-- | Algorithm to find route handlers by path
data FindRouteType = TreeFinder | PlainFinder

Expand Down

0 comments on commit 8c30d45

Please sign in to comment.