The wai-routes package

[Tags: library, mit]

Provides easy to use typesafe URLs for Wai Applications. See README for more information. Also see examples/ directory for usage examples.


[Skip to ReadMe]

Properties

Versions0.1, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1
Change logNone available
Dependenciesaeson (>=0.8 && <0.10), base (>=4.7 && <4.9), blaze-builder (==0.4.*), bytestring (==0.10.*), case-insensitive (==1.2.*), containers (==0.5.*), cookie (==0.4.*), data-default-class (==0.0.*), filepath (>=1.3 && <1.5), http-types (==0.8.*), mime-types (==0.1.*), monad-loops (==0.4.*), mtl (>=2.1 && <2.3), path-pieces (==0.2.*), random (==1.1.*), template-haskell (>=2.9 && <2.11), text (==1.2.*), wai (==3.0.*) [details]
LicenseMIT
AuthorAnupam Jain
Maintainerajnsit@gmail.com
StabilityExperimental
CategoryNetwork
Home pagehttps://ajnsit.github.io/wai-routes/
Source repositoryhead: git clone http://github.com/ajnsit/wai-routes
this: git clone http://github.com/ajnsit/wai-routes/tree/v0.8.1(tag v0.8.1)
UploadedTue Aug 25 11:44:12 UTC 2015 by AnupamJain
DistributionsLTSHaskell:0.7.3, NixOS:0.8.1, Stackage:0.8.1
Downloads2349 total (190 in last 30 days)
Votes
1 []
StatusDocs pending
Build status unknown [no reports yet]

Modules

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for wai-routes-0.8.1

Wai-Routes Hackage Hackage-Deps Build Status Coverage Status

Wai-routes is a micro web framework for Haskell that focuses on typesafe URLs.

Wai-routes is based on the Haskell Web Application Interface and uses it for most of the heavy lifting. It also provides a convenient but thin veneer over most of the wai API so it is unnecessary to directly use raw wai APIs when building web apps.

Much of Wai-route's typesafe URL functionality was pulled from the corresponding features in Yesod, and indeed the underlying aim of wai-routes is - "To provide a similar level of typesafe URL functionality to Wai applications as is available to Yesod applications.".

Features

Wai-routes adds the following features on top of wai -

Performance

When it comes to performance, Wai-routes compares quite favorably with other Haskell web development micro frameworks.

See more details here - philopon/apiary-benchmark

result

Example Usage

Wai-routes comes with several examples in the examples/ directory. New examples are being added regularly.

Example 1. Hello World - Code

A simple hello-world web app with two interlinked pages. This provides the simplest example of using routing and linking between pages with typesafe routes.

Example 2. Hello World with Subsites - Code

Similar functionality as the first example, but uses a hello world subsites to provide the hello world functionality. A subsite is an independently developed site that can be embedded into a parent site as long as the parent site satisfies a particular api contract. It's easy to swap out subsites for different functionality as long as the api contract remains constant.

Example 3. Using Blaze-HTML to generate HTML - Code

A simple example of how to generate HTML using blaze-html combinators in your handlers.

Example 4. Using Shakespearean Templates (hamlet, cassius, lucius, julius) to generate HTML/CSS/JS - Code

A simple example of how to generate HTML/CSS/JS using shakespearean templates. You can use both external and inline templates.

Example 5. Building a JSON REST Service - Code

Provides a simple example of how to build JSON REST services with wai-routes. Uses Aeson for JSON conversion. Note that this example just demonstrates the web facing side of the application. It doesn't permanently persist data, and is also not threadsafe. You must use a more robust data storage mechanism in production! An example of doing this with a Relational DB adapter (like persistent) is in the works.

Example 6. Stream a response - Code

Wai has had the ability to stream content for a long time. Now wai-routes exposes this functionality with the stream function. This example shows how to stream content in a handler. Note that most browsers using default settings will not show content as it is being streamed. You can use "curl" to observe the effect of streaming. E.g. - curl localhost:8080 will dump the data as it is being streamed from the server.

Planned Features

The following features are planned for later releases -

Changelog