The HTTPServer
module contains functions for serving olojs documents over
HTTP.
Creates a HTTP Server that mounts a store middleware
at /
.
server = HTTPServer.createServer(store);
server.listen(8010);
Creates an express middleware that exposes a RESTFul API to interact with an olojs store via HTTP.
middleware = HTTPServer.createMiddleware(store);
expressApp.use(mountPath, middleware);
-
On
GET /paht/to/doc
requests acceptingtext/*
, it will respond with the source of the document loaded viastore.read("/path/to/doc")
. -
On
GET /paht/to/doc
requests accepting other thantext/*
it will respond with a415
error code. -
The
GET
handler, on store'sReadPermissionDeniedError
will respond with the status code 403. -
The
GET
handler, on store'sReadOperationNotAllowedError
will respond with the status code 405. -
The
GET
handler, on any other error will respond with the status code 500. -
On
PUT /paht/to/doc
it will modify the document viastore.write("/path/to/doc", body)
. -
The
PUT
handler, on store'sWritePermissionDeniedError
will respond with the status code 403. -
The
PUT
handler, on store'sWriteOperationNotAllowedError
will respond with the status code 405. -
The
PUT
handler, on any other error will respond with the status code 500. -
On
DELETE /paht/to/doc
it will remove the document viastore.delete("/path/to/doc")
. -
The
DELETE
handler, on store'sWritePermissionDeniedError
will respond with the status code 403. -
The
DELETE
handler, on store'sWriteOperationNotAllowedError
will respond with the status code 405. -
The
DELETE
handler, on any other error will respond with the status code 500.