/
Batch.purs
46 lines (43 loc) · 949 Bytes
/
Batch.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Bucketchain.SimpleAPI.Batch where
import Foreign (Foreign)
-- | This is for internal. Do not use it.
type BatchParams = Array
{ path :: String
, body :: Foreign
}
-- | The type for enable batch operation.
-- |
-- | The batch operation is a mechanism running multiple `Proc` in one HTTP request.
-- |
-- | How to use:
-- |
-- | ```purescript
-- | withSimpleAPI appContext $ Batch { firstEndpoint, secondEndpoint }
-- | ```
-- |
-- | Request `POST /batch` with body:
-- |
-- | ```json
-- | [
-- | { "path": "/firstEndpoint" },
-- | { "path": "/secondEndpoint", "body": { "num": 1 } }
-- | ]
-- | ```
-- |
-- | You will get results like:
-- |
-- | ```json
-- | [
-- | {
-- | "status": 500,
-- | "body": { "message": "Internal server error" }
-- | },
-- | {
-- | "status": 201,
-- | "body": { "name": "foo" }
-- | }
-- | ]
-- | ```
-- |
-- | Note: `POST /batch` responds 200 always.
newtype Batch a = Batch a