Your objective is to build a simple JSON based REST Microservice. The service will provide search capabilities on an open source intelligence feed provided by AlienVault OTX. REST and microservices are fairly common, the goal here is to show how this might be done in a Clojure application using its functional capabilities.
# Run the application
make run# Or build and run the JAR
make build
make run-jar# Build and run
make docker-build
make docker-run
# Or stop the container
make docker-stophttp://localhost:8080/api-docs
- GET /indicators/:id :
Note: This currently uses
document/id, which is the top-level string ID. Alternatively,indicator/id(a long value within the inner vector) could be what is expected?
# curl http://localhost:8080/indicators/5b433d8fe822e72e3c57d26c
make api-indicator ID=5b3cb789bd391e24a8b1dc53- GET /indicators :
# curl http://localhost:8080/indicators
make api-indicators- GET /indicators?type=IPv4 :
# curl "http://localhost:8080/indicators?type=IPv4"
make api-indicators-type TYPE=IPv4- POST /indicators/search :
# curl -X POST http://localhost:8080/indicators/search \
# -H "Content-Type: application/json" \
# -d '{"adversary": "Plead"}'
make api-search QUERY='{"adversary":"Plead"}'
# curl -X POST http://localhost:8080/indicators/search \
# -H "Content-Type: application/json" \
# -d '{"author_name": "AlienVault"}'
make api-search QUERY='{"author_name":"AlienVault"}'Search Criteria Options
| Field | Type | Example |
|---|---|---|
adversary |
string | {"adversary": "Plead"} |
tlp |
string | {"tlp": "white"} |
author_name |
string | {"author_name": "AlienVault"} |
tags |
string or array | {"tags": "china"} or {"tags": ["china", "apt"]} |
industries |
string or array | {"industries": "tech"} |
targeted_countries |
string or array | {"targeted_countries": "Kuwait"} |
revision |
number | {"revision": 1} |
public |
number (0 or 1) | {"public": 1} |
- Check Health
make api-healthmake infomake format-check| Command | Description |
|---|---|
make run |
Run application locally |
make run-jar |
Build and run the JAR file |
make build |
Build uberjar |
make clean |
Clean build artifacts |
make test |
Run unit tests |
make format-check |
Check code formatting |
make docker-build |
Build Docker image |
make docker-run |
Run Docker container |
make docker-stop |
Stop Docker container |
make docker-clean |
Remove Docker image |
make info |
Show project information |
WIP on unit and integration testing with Speclj and Etaoin.
However, you can run the existing Clojure unit tests::
make test- clj-poly-doc
- component
- meetup
- polylith-gitbook
- usermanager-example
- furkan3ayraktar/clojure-polylith-realworld-example-app
- clojure-doc
- AI tools for certain syntax reminder and unit tests