Created
September 17, 2016 16:39
-
-
Save crdrost/95fb308f879947bf5f1966462bb1cdf4 to your computer and use it in GitHub Desktop.
How would ideal routing tables work?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyServer.Routes (route) where | |
import FictitiousRoutingLib | |
-- Can't decide if I'd rather embed this into do-notation or just use lists; seems like the type param | |
-- ends up being a phantom type in the end? | |
route :: HttpRouter x | |
route = do | |
-- one thing you always want is static serving of files: | |
dom "static.myapp.example.com" % staticServe "/var/www/staticAssets" | |
-- maybe also `(excludePatterns [] $ staticServe "...")` to specify "these things shall never be served from that dir." | |
-- so `staticServe :: FilePath -> RoutingAction ()` or so, with `dom :: Text -> RoutingFilter`, | |
-- and I suppose then (%) :: RoutingFilter -> RoutingAction x -> HttpRouter x. | |
-- possibly `type RoutingAction = HttpRouter`? All I care about from the calling library is: | |
-- doRouting :: HttpRequest -> HttpRouter x -> Maybe (RoutingAction x) | |
-- suggesting that `newtype HttpRouter x = Route (HttpRequest -> Maybe (RoutingAction x))` | |
-- Then since the above didn't match, we fall through to the next | |
dom "myapp.example.com" % do | |
seg "wiki" % do | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment