Browse Source

added a Cat model ready for CRUD

elm
parent
commit
167d320e4b
  1. 2
      Foundation.hs
  2. 12
      Handler/Cats.hs
  3. 1
      Model.hs
  4. 4
      config/models
  5. 3
      config/routes

2
Foundation.hs

@ -19,6 +19,8 @@ import Text.Jasmine (minifym)
import Text.Hamlet (hamletFile)
import Yesod.Core.Types (Logger)
import Data.Text (Text)
-- | The site argument for your application. This can be a good place to
-- keep settings and values requiring initialization before your application
-- starts running, such as database connections. Every handler will have

12
Handler/Cats.hs

@ -7,3 +7,15 @@ getCatsR = do
defaultLayout $ do
setTitle "Some Cats"
$(widgetFile "cats")
putCatsR :: Handler Html
putCatsR = error "putCatsR not yet defined"
getCatR :: Text -> Handler Html
getCatR _ = error "getCatR not yet defined"
putCatR :: Text -> Handler Html
putCatR _ = error "getCatR not yet defined"
deleteCatR :: Text -> Handler Html
deleteCatR _ = error "getCatR not yet defined"

1
Model.hs

@ -1,3 +1,4 @@
{-# LANGUAGE FlexibleInstances #-}
module Model where
import Yesod

4
config/models

@ -8,5 +8,9 @@ Email
user UserId Maybe
verkey Text Maybe
UniqueEmail email
Cat json
name Text
age Int Maybe
UniqueCat name
-- By default this file is used in Model.hs (which is imported by Foundation.hs)

3
config/routes

@ -5,4 +5,5 @@
/robots.txt RobotsR GET
/ HomeR GET POST
/cats CatsR GET
/cats CatsR GET PUT
/cat/#Text CatR GET PUT DELETE

Loading…
Cancel
Save