Skip to content

Commit

Permalink
Initial setup - simple ping server.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathankot committed Dec 21, 2014
0 parents commit 330431a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
cabal.sandbox.config
.cabal-sandbox
13 changes: 13 additions & 0 deletions App.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{-# LANGUAGE OverloadedStrings #-}

module App
( api
) where

import Web.Scotty
import Network.HTTP.Types

api :: ScottyM ()
api = get "/ping" $ do
status status200
text "back"
Empty file added LICENSE
Empty file.
11 changes: 11 additions & 0 deletions Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# LANGUAGE OverloadedStrings #-}

import Web.Scotty
import App (api)
import Util

main :: IO ()
main = do
port <- getEnvWithDefault "PORT" "3636"
scotty (read port) api

2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
11 changes: 11 additions & 0 deletions Util.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Util
( getEnvWithDefault
) where

import Data.Maybe
import System.Environment

getEnvWithDefault :: String -> String -> IO String
getEnvWithDefault name defaultValue = do
x <- lookupEnv name
return $ fromMaybe defaultValue x
27 changes: 27 additions & 0 deletions wed-is-socket.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Initial wed-is-socket.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/

name: wed-is-socket
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file: LICENSE
author: Nathan Kot
maintainer: me@nathankot.com
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10

executable wed-is-socket
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.8,
scotty,
websockets,
http-types
-- hs-source-dirs:
default-language: Haskell2010

0 comments on commit 330431a

Please sign in to comment.