Skip to main content

Nancy HTTP server

The Nancy HTTP server provides the capabilities of the Nancy library via an HTTP API, enabling remote computation as well as the implementation of wrapper libraries in any language that supports sending HTTP requests.

It is available on GitHub.

How it works​

The HTTP API is based on a declare then use scheme. When the user declares a curve, the server replies with its ID. Then, curve operations take IDs as operands and return the ID of the result.

This scheme reduces the communication overhead, since all the intermediate computations can be performed without transmitting the curve data back and forth.

In the example below, we show a series of requests that compute and retrieve the self-convolution of a curve.

For the full API, check the examples in the repository.

Declare the curve​

POST http://localhost:1006/curve HTTP/1.1
content-type: application/json

{
"type": "curve",
"baseSequence":
{
"elements": [
{
"type": "point",
"time": 0,
"value": 0
},
{
"type": "segment",
"startTime": 0,
"endTime": {
"num": 1,
"den": 3
},
"rightLimitAtStartTime": 0,
"slope": 0
},
{
"type": "point",
"time": {
"num": 1,
"den": 3
},
"value": 0
},
{
"type": "segment",
"startTime": {
"num": 1,
"den": 3
},
"endTime": 3,
"rightLimitAtStartTime": 0,
"slope": 0
},
{
"type": "point",
"time": 3,
"value": 0
},
{
"type": "segment",
"startTime": 3,
"endTime": {
"num": 10,
"den": 3
},
"rightLimitAtStartTime": 0,
"slope": 12
}
]
},
"pseudoPeriodStart": {
"num": 1,
"den": 3
},
"pseudoPeriodLength": 3,
"pseudoPeriodHeight": 4
}
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json; charset=utf-8
Date: Tue, 05 Dec 2023 10:57:30 GMT
Server: Kestrel
Transfer-Encoding: chunked

{
"id": "883D5A67"
}

Compute the self-convolution​

POST http://localhost:1006/curve/convolution HTTP/1.1
content-type: application/json

[
"883D5A67",
"883D5A67"
]
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json; charset=utf-8
Date: Tue, 05 Dec 2023 10:59:04 GMT
Server: Kestrel
Transfer-Encoding: chunked

"7419A1DF"

Retrieve the result​

GET http://localhost:1006/curve/7419A1DF HTTP/1.1
content-type: application/json
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json; charset=utf-8
Date: Tue, 05 Dec 2023 10:59:43 GMT
Server: Kestrel
Transfer-Encoding: chunked

{
"curve": {
"type": "curve",
"baseSequence": {
"elements": [
{
"type": "point",
"time": 0,
"value": 0
},
{
"type": "segment",
"startTime": 0,
"endTime": {
"num": 10,
"den": 3
},
"rightLimitAtStartTime": 0,
"slope": 0
},
{
"type": "point",
"time": {
"num": 10,
"den": 3
},
"value": 0
},
{
"type": "segment",
"startTime": {
"num": 10,
"den": 3
},
"endTime": 6,
"rightLimitAtStartTime": 0,
"slope": 0
},
{
"type": "point",
"time": 6,
"value": 0
},
{
"type": "segment",
"startTime": 6,
"endTime": {
"num": 19,
"den": 3
},
"rightLimitAtStartTime": 0,
"slope": 12
}
]
},
"pseudoPeriodStart": {
"num": 10,
"den": 3
},
"pseudoPeriodLength": 3,
"pseudoPeriodHeight": 4
}
}