yesod-0.5.4: Creation of type-safe, RESTful web applications.

Yesod.WebRoutes

Description

This module should be removed when web-routes incorporates necessary support.

Synopsis

Documentation

encodePathInfo :: [String] -> [(String, String)] -> String

Encodes a list of path segments into a valid URL fragment.

This function takes the following three steps:

  • UTF-8 encodes the characters.
  • Performs percent encoding on all unreserved characters, as well as :@=+$,
  • Intercalates with a slash.

For example:

 encodePathInfo [\"foo\", \"bar\", \"baz\"]

"foo/bar/baz"

 encodePathInfo [\"foo bar\", \"baz\/bin\"]

"foo%20bar/baz%2Fbin"

 encodePathInfo [\"\"]

"%D7%A9%D7%9C%D7%95%D7%9D"

data Site url a

A site groups together the three functions necesary to make an application:

  • A function to convert from the URL type to path segments.
  • A function to convert from path segments to the URL, if possible.
  • A function to return the application for a given URL.

There are two type parameters for Site: the first is the URL datatype, the second is the application datatype. The application datatype will depend upon your server backend.

Constructors

Site 

Fields

handleSite :: (url -> [(String, String)] -> String) -> url -> a

Return the appropriate application for a given URL.

The first argument is a function which will give an appropriate URL (as a String) for a URL datatype. This is usually constructed by a combination of formatPathSegments and the prepending of an absolute application root.

Well behaving applications should use this function to generating all internal URLs.

formatPathSegments :: url -> ([String], [(String, String)])

This function must be the inverse of parsePathSegments.

parsePathSegments :: [String] -> Either String url

This function must be the inverse of formatPathSegments.

Instances

Functor (Site url)