-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documentation and a working container image
- Loading branch information
1 parent
900849a
commit ff8c625
Showing
11 changed files
with
76 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM golang:1.13 as builder | ||
COPY . /coap-hooks-router | ||
WORKDIR /coap-hooks-router | ||
ENV CGO_ENABLED 0 | ||
RUN go build -o server . | ||
|
||
FROM scratch as release | ||
ARG ADMIN_BEARER | ||
WORKDIR / | ||
VOLUME /dbdata | ||
COPY --from=builder /coap-hooks-router/server /server | ||
ENTRYPOINT ["/server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
run: | ||
go run main.go | ||
dev: | ||
go run main.go | ||
|
||
docker-build: | ||
docker build -t coap-hooks-router . | ||
|
||
docker-run: | ||
docker run -v container-db:/dbdata -e ADMIN_BEARER=${ADMIN_BEARER} -p 8081:8081 -p 5683:5683 coap-hooks-router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
# To Run | ||
- `cp .env.example .env` | ||
- generate your ADMIN_BEARER | ||
- `make run` | ||
# CoAP Webhooks Router | ||
|
||
# To create a new hook | ||
## To Run | ||
- generate your ADMIN_BEARER (`openssl rand -base64 27` can do it) and export ADMIN_BEARER="generatedbearertokenvalue" in your shell | ||
- `make dev` for local run | ||
- `make docker-run` for local docker run (functionally the same as the previous) | ||
- `make docker-build` to build the docker image | ||
- the Admin Hooks API runs on 8081, and the CoAP server runs on 5683 | ||
|
||
## Using the Hooks API | ||
|
||
### Create a new hook | ||
- `curl -v -d '{"owner":"{OWNER_NAME}","name":"{HOOK_NAME}","destination":"{HTTPS_ADDRESS}"}' -H "Content-Type:application/json" -H "Authorization: Bearer {BEARER}" http://localhost:8081/api/hooks/` | ||
|
||
# To list all hooks for an owner | ||
### List all hooks for an owner | ||
- `curl -v -H "Accept:application/json" -H "Authorization: Bearer {BEARER}" http://localhost:8081/api/hooks/{OWNER_NAME}` | ||
|
||
### List all hooks existing in the system | ||
- `curl -v -H "Accept:application/json" -H "Authorization: Bearer {BEARER}" http://localhost:8081/api/hooks` | ||
|
||
### Delete an existing hook by name | ||
- `curl -v -X DELETE -H "Content-Type:application/json" -H "Authorization: Bearer {BEARER}" http://localhost:8081/api/hooks/{OWNER_NAME}/{HOOK_NAME}` | ||
|
||
### Delete all hooks for an owner | ||
- `curl -v -X DELETE -H "Content-Type:application/json" -H "Authorization: Bearer {BEARER}" http://localhost:8081/api/hooks/{OWNER_NAME}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters