diff options
author | dan <[email protected]> | 2024-04-20 14:01:50 -0400 |
---|---|---|
committer | dan <[email protected]> | 2024-04-20 14:01:50 -0400 |
commit | 0f0b7f8b9dbe468eba2d491f6cc3c3088e7a4467 (patch) | |
tree | 933c038f2dfa852ae1df648e15267b7401c188d9 | |
parent | 66666390b3c553bdeebb0bcf8a6ddc7fd1e1d72b (diff) | |
download | bizexp-0f0b7f8b9dbe468eba2d491f6cc3c3088e7a4467.tar.gz bizexp-0f0b7f8b9dbe468eba2d491f6cc3c3088e7a4467.tar.bz2 bizexp-0f0b7f8b9dbe468eba2d491f6cc3c3088e7a4467.zip |
feat: new endpoints to eval expressions with and without table contexts
-rwxr-xr-x | src/RestService.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/RestService.hs b/src/RestService.hs index 3bad9b6..983deda 100755 --- a/src/RestService.hs +++ b/src/RestService.hs @@ -82,6 +82,12 @@ routes state = do S.json . fmap (evalTableExpressions . flip TableExpressions [ex]) =<< liftIO (getTable state id) + post "/t/:id/e" $ do + id <- S.pathParam "id" + exs <- S.jsonData + S.json + . fmap (evalTableExpressions . flip TableExpressions exs) + =<< liftIO (getTable state id) post "/t/:id" $ do id <- S.pathParam "id" S.json =<< liftIO . setTable state id =<< S.jsonData @@ -89,7 +95,11 @@ routes state = do id <- S.pathParam "id" S.json =<< liftIO . insertRow state id =<< S.jsonData get "/:expr" $ - S.text =<< S.pathParam "expr" + S.text + . (fromMaybe "") + . result + . (ExprReq <*> eval M.empty) + =<< S.pathParam "expr" post "/eval" $ S.json . (ExprReq <*> eval M.empty) . expression =<< S.jsonData |