From 0f0b7f8b9dbe468eba2d491f6cc3c3088e7a4467 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Apr 2024 14:01:50 -0400 Subject: feat: new endpoints to eval expressions with and without table contexts --- src/RestService.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3