-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Happstack support for reform. -- -- Reform is a library for building and validating forms using -- applicative functors. This package add support for using reform with -- Happstack. @package reform-happstack @version 0.1 -- | Support for using Reform with the Haskell Web Framework Happstack. -- http://happstack.com/ module Text.Reform.Happstack -- | create an Environment to be used with runForm environment :: Happstack m => Environment m [Input] -- | similar to 'eitherForm environment' but includes double-submit (Cross -- Site Request Forgery) CSRF protection. -- -- The form must have been created using happstackViewForm -- -- see also: happstackViewForm happstackEitherForm :: Happstack m => ([(String, String)] -> view -> view) -> String -> Form m [Input] error view proof a -> m (Either view a) -- | similar to viewForm but includes double-submit (Cross Site -- Request Forgery) CSRF protection. -- -- Must be used with happstackEitherForm. -- -- see also: happstackEitherForm. happstackViewForm :: Happstack m => ([(String, String)] -> view -> view) -> String -> Form m input error view proof a -> m view -- | Utility Function: wrap the view in a <form> -- that includes double-submit CSRF protection. -- -- calls addCSRFCookie to set the cookie and adds the token as a -- hidden field. -- -- see also: happstackViewForm, happstackEitherForm, -- checkCSRF happstackView :: Happstack m => ([(String, String)] -> view -> view) -> String -> view -> m view -- | Utility Function: add a cookie for CSRF protection addCSRFCookie :: Happstack m => String -> m String -- | Utility Function: get CSRF protection cookie getCSRFCookie :: Happstack m => String -> m String -- | Utility Function: check that the CSRF cookie and hidden field exist -- and are equal -- -- If the check fails, this function will call: -- --
-- escape $ forbidden (toResponse "CSRF check failed.") --checkCSRF :: Happstack m => String -> m () -- | generate the name to use for the csrf cookie -- -- Currently this returns the static cookie reform-csrf. Using the -- prefix would allow csrfName :: String -- | This function allows you to embed a a single Form into a HTML -- page. -- -- In general, you will want to use the reform function instead, -- which allows more than one Form to be used on the same page. -- -- see also: reform reformSingle :: (ToMessage b, Happstack m, Alternative m, Monoid view) => ([(String, String)] -> view -> view) -> String -> (a -> m b) -> Maybe ([(FormRange, error)] -> view -> m b) -> Form m [Input] error view proof a -> m view -- | this function embeds a Form in an HTML page. -- -- When the page is requested with a GET request, the form view -- will be rendered. -- -- When the page is requested with a POST request, the form data -- will be extracted and validated. -- -- If a value is successfully produced the success handler will be called -- with the value. -- -- On failure the failure handler will be called. If no failure handler -- is provided, then the page will simply be redisplayed. The form will -- be rendered with the errors and previous submit data shown. -- -- The first argument to reform is a function which generates the -- <form> tag. It should generally come from the template -- library you are using, such as the form function from -- reform-hsp. -- -- The [(String, String)] argument is a list of '(name, value)' -- pairs for extra hidden fields that should be added to the -- <form> tag. These hidden fields are used to provide -- cross-site request forgery (CSRF) protection, and to support multiple -- forms on the same page. reform :: (ToMessage b, Happstack m, Alternative m, Monoid view) => ([(String, String)] -> view -> view) -> String -> (a -> m b) -> Maybe ([(FormRange, error)] -> view -> m b) -> Form m [Input] error view proof a -> m view instance FormInput [Input]