airship-0.9.5: A Webmachine-inspired HTTP library
Safe HaskellNone
LanguageHaskell2010

Airship.Route

Synopsis

Documentation

data Route Source #

Routes represent chunks of text used to match over URLs. You match hardcoded paths with string literals (and the -XOverloadedStrings extension), named variables with the var combinator, and wildcards with star.

Instances

Instances details
Show Route Source # 
Instance details

Defined in Airship.Internal.Route

Methods

showsPrec :: Int -> Route -> ShowS #

show :: Route -> String #

showList :: [Route] -> ShowS #

IsString Route Source # 
Instance details

Defined in Airship.Internal.Route

Methods

fromString :: String -> Route #

Semigroup Route Source # 
Instance details

Defined in Airship.Internal.Route

Methods

(<>) :: Route -> Route -> Route #

sconcat :: NonEmpty Route -> Route #

stimes :: Integral b => b -> Route -> Route #

Monoid Route Source # 
Instance details

Defined in Airship.Internal.Route

Methods

mempty :: Route #

mappend :: Route -> Route -> Route #

mconcat :: [Route] -> Route #

data RoutingSpec m a Source #

Represents a fully-specified set of routes that map paths (represented as Routes) to Resources. RoutingSpecs are declared with do-notation, to wit:

   myRoutes :: RoutingSpec IO ()
   myRoutes = do
     root                                 #> myRootResource
     "blog" </> var "date" </> var "post" #> blogPostResource
     "about"                              #> aboutResource
     "anything" </> star                  #> wildcardResource

Instances

Instances details
Monad (RoutingSpec m) Source # 
Instance details

Defined in Airship.Internal.Route

Methods

(>>=) :: RoutingSpec m a -> (a -> RoutingSpec m b) -> RoutingSpec m b #

(>>) :: RoutingSpec m a -> RoutingSpec m b -> RoutingSpec m b #

return :: a -> RoutingSpec m a #

Functor (RoutingSpec m) Source # 
Instance details

Defined in Airship.Internal.Route

Methods

fmap :: (a -> b) -> RoutingSpec m a -> RoutingSpec m b #

(<$) :: a -> RoutingSpec m b -> RoutingSpec m a #

Applicative (RoutingSpec m) Source # 
Instance details

Defined in Airship.Internal.Route

Methods

pure :: a -> RoutingSpec m a #

(<*>) :: RoutingSpec m (a -> b) -> RoutingSpec m a -> RoutingSpec m b #

liftA2 :: (a -> b -> c) -> RoutingSpec m a -> RoutingSpec m b -> RoutingSpec m c #

(*>) :: RoutingSpec m a -> RoutingSpec m b -> RoutingSpec m b #

(<*) :: RoutingSpec m a -> RoutingSpec m b -> RoutingSpec m a #

MonadWriter [(ByteString, RouteLeaf m)] (RoutingSpec m) Source # 
Instance details

Defined in Airship.Internal.Route

Methods

writer :: (a, [(ByteString, RouteLeaf m)]) -> RoutingSpec m a #

tell :: [(ByteString, RouteLeaf m)] -> RoutingSpec m () #

listen :: RoutingSpec m a -> RoutingSpec m (a, [(ByteString, RouteLeaf m)]) #

pass :: RoutingSpec m (a, [(ByteString, RouteLeaf m)] -> [(ByteString, RouteLeaf m)]) -> RoutingSpec m a #

data RouteLeaf m Source #

Instances

Instances details
MonadWriter [(ByteString, RouteLeaf m)] (RoutingSpec m) Source # 
Instance details

Defined in Airship.Internal.Route

Methods

writer :: (a, [(ByteString, RouteLeaf m)]) -> RoutingSpec m a #

tell :: [(ByteString, RouteLeaf m)] -> RoutingSpec m () #

listen :: RoutingSpec m a -> RoutingSpec m (a, [(ByteString, RouteLeaf m)]) #

pass :: RoutingSpec m (a, [(ByteString, RouteLeaf m)] -> [(ByteString, RouteLeaf m)]) -> RoutingSpec m a #

data Trie a #

A map from ByteStrings to a. For all the generic functions, note that tries are strict in the Maybe but not in a.

The Monad instance is strange. If a key k1 is a prefix of other keys, then results from binding the value at k1 will override values from longer keys when they collide. If this is useful for anything, or if there's a more sensible instance, I'd be curious to know.

Instances

Instances details
Monad Trie

Since: bytestring-trie-0.2.2

Instance details

Defined in Data.Trie.Internal

Methods

(>>=) :: Trie a -> (a -> Trie b) -> Trie b #

(>>) :: Trie a -> Trie b -> Trie b #

return :: a -> Trie a #

Functor Trie 
Instance details

Defined in Data.Trie.Internal

Methods

fmap :: (a -> b) -> Trie a -> Trie b #

(<$) :: a -> Trie b -> Trie a #

Applicative Trie

Since: bytestring-trie-0.2.2

Instance details

Defined in Data.Trie.Internal

Methods

pure :: a -> Trie a #

(<*>) :: Trie (a -> b) -> Trie a -> Trie b #

liftA2 :: (a -> b -> c) -> Trie a -> Trie b -> Trie c #

(*>) :: Trie a -> Trie b -> Trie b #

(<*) :: Trie a -> Trie b -> Trie a #

Foldable Trie 
Instance details

Defined in Data.Trie.Internal

Methods

fold :: Monoid m => Trie m -> m #

foldMap :: Monoid m => (a -> m) -> Trie a -> m #

foldMap' :: Monoid m => (a -> m) -> Trie a -> m #

foldr :: (a -> b -> b) -> b -> Trie a -> b #

foldr' :: (a -> b -> b) -> b -> Trie a -> b #

foldl :: (b -> a -> b) -> b -> Trie a -> b #

foldl' :: (b -> a -> b) -> b -> Trie a -> b #

foldr1 :: (a -> a -> a) -> Trie a -> a #

foldl1 :: (a -> a -> a) -> Trie a -> a #

toList :: Trie a -> [a] #

null :: Trie a -> Bool #

length :: Trie a -> Int #

elem :: Eq a => a -> Trie a -> Bool #

maximum :: Ord a => Trie a -> a #

minimum :: Ord a => Trie a -> a #

sum :: Num a => Trie a -> a #

product :: Num a => Trie a -> a #

Traversable Trie 
Instance details

Defined in Data.Trie.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Trie a -> f (Trie b) #

sequenceA :: Applicative f => Trie (f a) -> f (Trie a) #

mapM :: Monad m => (a -> m b) -> Trie a -> m (Trie b) #

sequence :: Monad m => Trie (m a) -> m (Trie a) #

Eq1 Trie

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Methods

liftEq :: (a -> b -> Bool) -> Trie a -> Trie b -> Bool #

Ord1 Trie

Warning: This instance suffers unnecessarily from Bug #25.

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Methods

liftCompare :: (a -> b -> Ordering) -> Trie a -> Trie b -> Ordering #

Read1 Trie

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Trie a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Trie a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Trie a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Trie a] #

Show1 Trie

Warning: This instance suffers Bug #25.

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Trie a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Trie a] -> ShowS #

IsList (Trie a)

Warning: The toList method of this instance suffers Bug #25.

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Associated Types

type Item (Trie a) #

Methods

fromList :: [Item (Trie a)] -> Trie a #

fromListN :: Int -> [Item (Trie a)] -> Trie a #

toList :: Trie a -> [Item (Trie a)] #

Eq a => Eq (Trie a) 
Instance details

Defined in Data.Trie.Internal

Methods

(==) :: Trie a -> Trie a -> Bool #

(/=) :: Trie a -> Trie a -> Bool #

Ord a => Ord (Trie a)

Warning: This instance suffers unnecessarily from Bug #25.

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Methods

compare :: Trie a -> Trie a -> Ordering #

(<) :: Trie a -> Trie a -> Bool #

(<=) :: Trie a -> Trie a -> Bool #

(>) :: Trie a -> Trie a -> Bool #

(>=) :: Trie a -> Trie a -> Bool #

max :: Trie a -> Trie a -> Trie a #

min :: Trie a -> Trie a -> Trie a #

Read a => Read (Trie a)

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Show a => Show (Trie a)

Warning: This instance suffers Bug #25.

Since: bytestring-trie-0.2.2

Instance details

Defined in Data.Trie.Internal

Methods

showsPrec :: Int -> Trie a -> ShowS #

show :: Trie a -> String #

showList :: [Trie a] -> ShowS #

Semigroup a => Semigroup (Trie a)

Since: bytestring-trie-0.2.5

Instance details

Defined in Data.Trie.Internal

Methods

(<>) :: Trie a -> Trie a -> Trie a #

sconcat :: NonEmpty (Trie a) -> Trie a #

stimes :: Integral b => b -> Trie a -> Trie a #

Monoid a => Monoid (Trie a) 
Instance details

Defined in Data.Trie.Internal

Methods

mempty :: Trie a #

mappend :: Trie a -> Trie a -> Trie a #

mconcat :: [Trie a] -> Trie a #

Binary a => Binary (Trie a) 
Instance details

Defined in Data.Trie.Internal

Methods

put :: Trie a -> Put #

get :: Get (Trie a) #

putList :: [Trie a] -> Put #

NFData a => NFData (Trie a)

Since: bytestring-trie-0.2.7

Instance details

Defined in Data.Trie.Internal

Methods

rnf :: Trie a -> () #

type Item (Trie a) 
Instance details

Defined in Data.Trie.Internal

type Item (Trie a) = (ByteString, a)

root :: Route Source #

Represents the root resource (/). This should usually be the first path declared in a RoutingSpec.

var :: Text -> Route Source #

Captures a named in a route and adds it to the routingParams hashmap under the provided Text value. For example,

   "blog" </> var "date" </> var "post"

will capture all URLs of the form /blog/$date/$post, and add date and post to the routingParams contained within the resource this route maps to.

star :: Route Source #

Captures a wildcard route. For example,

   "emcees" </> star

will match /emcees, /emcees/biggie, /emcees/earl/vince, and so on and so forth.

(</>) :: Route -> Route -> Route Source #

a </> b separates the path components a and b with a slash. This is actually just a synonym for mappend.

(#>=) :: MonadWriter [(ByteString, RouteLeaf a)] m => Route -> m (Resource a) -> m () Source #

runRouter :: RoutingSpec m a -> Trie (RouteLeaf m) Source #

Turns the list of routes in a RoutingSpec into a Trie for efficient routing