aboutsummaryrefslogtreecommitdiff
path: root/server/src/Main.hs
diff options
context:
space:
mode:
authorJoris2019-10-12 11:23:10 +0200
committerJoris2019-10-12 11:23:10 +0200
commit52331eeadce8d250564851c25fc965172640bc55 (patch)
treee634c6d232d9a28384499fe19caeb80288d05df9 /server/src/Main.hs
parent7529a18ff0ac443e7f9764b5e2d0f57a5d3a850b (diff)
downloadbudget-52331eeadce8d250564851c25fc965172640bc55.tar.gz
budget-52331eeadce8d250564851c25fc965172640bc55.tar.bz2
budget-52331eeadce8d250564851c25fc965172640bc55.zip
Implement client routing
Diffstat (limited to 'server/src/Main.hs')
-rw-r--r--server/src/Main.hs36
1 files changed, 20 insertions, 16 deletions
diff --git a/server/src/Main.hs b/server/src/Main.hs
index 0ccf5e2..e3dad9e 100644
--- a/server/src/Main.hs
+++ b/server/src/Main.hs
@@ -15,48 +15,52 @@ main = do
conf <- Conf.get "application.conf"
_ <- runDaemons conf
S.scotty (Conf.port conf) $ do
- S.middleware $ W.gzip $ W.def { W.gzipFiles = GzipCompress }
- S.middleware . staticPolicy $ noDots >-> addBase "public"
- S.get "/" $ do
- Index.get conf
+ S.middleware $
+ W.gzip $ W.def { W.gzipFiles = GzipCompress }
+
+ S.middleware . staticPolicy $
+ noDots >-> addBase "public"
- S.post "/askSignIn" $ do
+ S.post "/api/askSignIn" $
S.jsonData >>= Index.askSignIn conf
- S.get "/signIn/:signInToken" $ do
+ S.get "/api/signIn/:signInToken" $ do
signInToken <- S.param "signInToken"
Index.trySignIn conf signInToken
- S.post "/signOut" $
+ S.post "/api/signOut" $
Index.signOut conf
- S.post "/payment" $
+ S.post "/api/payment" $
S.jsonData >>= Payment.create
- S.put "/payment" $
+ S.put "/api/payment" $
S.jsonData >>= Payment.edit
- S.delete "/payment/:id" $ do
+ S.delete "/api/payment/:id" $ do
paymentId <- S.param "id"
Payment.delete paymentId
- S.post "/income" $
+ S.post "/api/income" $
S.jsonData >>= Income.create
- S.put "/income" $
+ S.put "/api/income" $
S.jsonData >>= Income.edit
- S.delete "/income/:id" $ do
+ S.delete "/api/income/:id" $ do
incomeId <- S.param "id"
Income.delete incomeId
- S.post "/category" $
+ S.post "/api/category" $
S.jsonData >>= Category.create
- S.put "/category" $
+ S.put "/api/category" $
S.jsonData >>= Category.edit
- S.delete "/category/:id" $ do
+ S.delete "/api/category/:id" $ do
categoryId <- S.param "id"
Category.delete categoryId
+
+ S.notFound $
+ Index.get conf