XTBSG4C7SCZUFOU2BTNFR6B6TCGYI35BWUV4PVTS3N7KNH5VEARQC
EZQG2APB36DDMIAYDPPDGOIXOD7K2RZZSGC2NKGZIHB2HZBTW7EQC
LD4GLVSF6YTA7OZWIGJ45H6TUXGM4WKUIYXKWQFNUP36WDMYSMXAC
IZEVQF627FA7VV25KJAWYWGGC35LZUUBBQRPN5ZAINTQLPEDRTEAC
W35DDBFYF6Z4ZPCFEO5RPAONZLYCSNTXUSTS6FIUUVZHCI6Q7GHAC
Z7KS5XHHC6PAMTVBHXY7KUSS3BWAOU6FSYIITUCFOOJZU4OUJHBAC
4IQVQL4TS35GL2GYZJG254TKJLL5EHMRSFT77Z4VTRZIG2TMBM3QC
2Y2QZFVFSKXEFEGYJB5A7GI735ONWPCF7DVTIY5T73AUEVTZTBBQC
ADMKQQGCGVSHHIMVQ4XFRDCG544SBJCYALSKZV45CQQBZ4ACUH2AC
64C6AWH66FDKU6UE6Z6JPX2J2GBM2JOPTH2GL6LHKAIUBGNGDZ5AC
2G3GNDDUOVPF45PELJ65ZB2IXEHJJXJILFRVHZXGPXUL4BVNZJFQC
PBD7LZYQHXAA3KLH2ZUX5GW4UFML6BQ32KXZF4KZ6OYFASUYFJ5QC
BROSTG5KP3NUNLSYPVQID254TE47E5RKQAKLPIY7PGWETE6JNMTAC
I2KHGVD44KT4MQJXGCTVSQKMBO6TVCY72F26TLXGWRL6PHGF6RNQC
instance ToJSON WidxJ where
toJSON (WidxJ widx) =
toJSON $ (fmap IntervalJ) <$> (M.mapKeysWith (++) (^._BtcAddr) widx)
, ("projects/:projectId/log/:btcAddr", method GET loggedIntervalsHandler)
, ("projects/:projectId", method GET ok)
, ("projects", void $ method POST projectCreateHandler)
, ("projects", void $ method GET projectListHandler)
, ("payouts/:projectId", method GET payoutsHandler)
, ("projects/:projectId/log/:btcAddr", serveJSON WidxJ $ method GET loggedIntervalsHandler)
, ("projects/:projectId", serveJSON ProjectJ $ method GET projectGetHandler)
, ("projects", void $ method POST projectCreateHandler)
, ("projects", serveJSON (fmap (ProjectJ._project)) $ method GET projectListHandler)
, ("payouts/:projectId", serveJSON PayoutsJ $ method GET payoutsHandler)
serveJSON :: (MonadSnap m, A.ToJSON a) => (b -> a) -> m b -> m ()
serveJSON f ma = do
modifyResponse $ addHeader "content-type" "application/json"
writeLBS =<< (A.encode . f <$> ma)
widx <- liftPG . runReaderT $ readWorkIndex pid
modifyResponse $ addHeader "content-type" "application/json"
writeLBS . A.encode . fmap (fmap IntervalJ) $ M.mapKeysWith (++) (^._BtcAddr) widx
liftPG . runReaderT $ readWorkIndex pid