Interactive code snippets not yet available for SoH 2.0, see our Status of of School of Haskell 2.0 blog post

Method override

Related to: http://stackoverflow.com/questions/22902419/yesod-put-and-delete-using-hidden-method-parameter/22903897.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes       #-}
{-# LANGUAGE TemplateHaskell   #-}
{-# LANGUAGE TypeFamilies      #-}
import Yesod.Core

data App = App

mkYesod "App" [parseRoutes|
/ HomeR GET POST PUT
|]

instance Yesod App

getHomeR :: Handler Html
getHomeR = defaultLayout
    [whamlet|
        <form method=post action=@{HomeR}?_method=PUT>
            <button>This should be a PUT
    |]

postHomeR :: Handler Html
postHomeR = defaultLayout [whamlet|POST|]

putHomeR :: Handler Html
putHomeR = defaultLayout [whamlet|PUT|]

main :: IO ()
main = warpEnv App
comments powered by Disqus