Skip to content

Instantly share code, notes, and snippets.

@rlucha
Created October 5, 2017 22:56
Show Gist options
  • Select an option

  • Save rlucha/101fbea2d0a5a6496b0b197e8a07791a to your computer and use it in GitHub Desktop.

Select an option

Save rlucha/101fbea2d0a5a6496b0b197e8a07791a to your computer and use it in GitHub Desktop.
-- Scotty server example
-- {-# LANGUAGE OverloadedStrings #-}
--
-- module Main where
--
-- import Web.Scotty
-- import Control.Monad.IO.Class
--
-- import Db
--
-- getUserHandler :: ActionM()
-- getUserHandler = do
-- id <- param "id"
-- user <- liftIO (Db.getUser id) -- liftIO to actionM
-- json user
--
-- getAllUsersHandler :: ActionM()
-- getAllUsersHandler = do
-- users <- liftIO Db.getAllUsers -- liftIO to actionM
-- json users
--
-- createRoom :: ActionM()
-- createRoom = do
-- room <- params
-- text (room)
--
-- getFirstParam :: Param -> String
-- getFirstParam param = (head Param)
--
-- routes :: ScottyM ()
-- routes = do
-- get "/users" getAllUsersHandler
-- get "/users/:id" getUserHandler
-- post "/rooms/create" createRoom
--
-- main :: IO ()
-- main = do
-- putStrLn "Starting Server..."
-- scotty 4888 routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment