2017-09-23 01:55:29 +02:00
|
|
|
# Mainflux HTTP adapter
|
|
|
|
|
|
|
|
Mainflux HTTP adapter provides an HTTP API for sending messages through the
|
|
|
|
platform.
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
The service is configured using the environment variables presented in the
|
|
|
|
following table. Note that any unset variables will be replaced with their
|
|
|
|
default values.
|
|
|
|
|
2017-12-11 14:18:42 +01:00
|
|
|
| Variable | Description | Default |
|
|
|
|
|-----------------------|-------------------|-----------------------|
|
|
|
|
| HTTP_ADAPTER_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
2017-09-23 01:55:29 +02:00
|
|
|
|
|
|
|
## Deployment
|
|
|
|
|
|
|
|
The service is distributed as Docker container. The following snippet provides
|
|
|
|
a compose file template that can be used to deploy the service container locally:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
version: "2"
|
|
|
|
services:
|
|
|
|
adapter:
|
|
|
|
image: mainflux/http-adapter:[version]
|
|
|
|
container_name: [instance name]
|
|
|
|
ports:
|
|
|
|
- [host machine port]:8180
|
|
|
|
environment:
|
2017-12-11 14:18:42 +01:00
|
|
|
HTTP_ADAPTER_NATS_URL: [NATS instance URL]
|
2017-09-23 01:55:29 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
To start the service outside of the container, execute the following shell script:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# download the latest version of the service
|
2017-11-22 12:51:32 +01:00
|
|
|
go get github.com/mainflux/mainflux
|
2017-09-23 01:55:29 +02:00
|
|
|
|
2017-11-22 12:51:32 +01:00
|
|
|
cd $GOPATH/src/github.com/mainflux/mainflux/cmd/http
|
2017-09-23 01:55:29 +02:00
|
|
|
|
|
|
|
# compile the app; make sure to set the proper GOOS value
|
|
|
|
CGO_ENABLED=0 GOOS=[platform identifier] go build -ldflags "-s" -a -installsuffix cgo -o app
|
|
|
|
|
|
|
|
# set the environment variables and run the service
|
2017-12-11 14:18:42 +01:00
|
|
|
HTTP_ADAPTER_NATS_URL=[NATS instance URL] app
|
2017-09-23 01:55:29 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
For more information about service capabilities and its usage, please check out
|
|
|
|
the [API documentation](swagger.yaml).
|