A REST web service for Mellon controllers https://github.com/dhess/mellon/
|Latest on Hackage:||0.7.0.3|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
mellon-web package wraps a
mellon-core controller in a REST
web service, making it possible to control physical access devices
from an HTTP client. The package includes both a WAI application
server, and native Haskell client bindings for the service.
mellon-core controller interface, the
mellon-web REST API
is quite simple. There are only 3 methods:
GET /timereturns the system time on the server. This is made available for diagnostic purposes, primarily to ensure the server has an accurate clock.
GET /statereturns the controller's current state (either
dateis the UTC time at which the controller will automatically lock again).
PUT /statesets the controller's current state. Use this method to lock and unlock the controller.
See API.md for detailed documentation on the REST service.
Note that the
mellon-web server does not provide an authentication
mechanism! You should proxy it behind a secure, authenticating HTTPS
server such as Nginx.
An extremely simple example server (with on-line documentation
support) is provided in the
examples directory. You can run it with
cabal run mock-mellon-server and test it using the endpoints
described in API.md. The server is will run on the
localhost loopback interface on port 8081.
Also included is a Paw file with a
localhost environment for use with the example server.
This particular example server uses a "mock lock" device which only internally logs lock and unlock events without depending on any actual hardware, so it will run anywhere.
Another included example server uses the
mellon-gpio package to
drive a simple physical access device via a GPIO pin. This server must
be run on a Linux host with GPIO hardware, e.g., a Raspberry Pi
This server takes a GPIO pin number and a local port number, then
mellon-web server on all local interfaces on the specified
port. When the server receives an unlock request, it will drive a high
signal on the specified GPIO pin. When the unlock expires, or when the
server receives a lock request, it will drive a low signal on the
specified GPIO pin.
To use this server, simply connect a properly-designed physical access device (e.g., an electric strike driven by a relay circuit such as the one shown here) to an available GPIO pin on the host device, then run the server with the specified GPIO pin number and port. For example, to run the server on port 7533 using GPIO pin 65:
cabal run gpio-mellon-server -- sysfs --port 7533 65
sysfs command tells the server to use the Linux
interpreter. (Currently, this is the only supported GPIO platform.)
NOTE: the REST service provided by
gpio-mellon-server offers no
security/authentication for your access control device! You should
always run it (or any
mellon-web server) behind a secure proxy web
service or equivalent HTTP(S)-based authentication mechanism.
Bump servant upper bounds.
Add an "--active-low" flag to
Packaging fixes only.
- Port to new
- Fix Servant bitrot.