GitXplorerGitXplorer
r

protean-beers

public
0 stars
0 forks
0 issues

Commits

List of commits on branch develop.
Unverified
18463f7b6a3ccae8703b61a8b1a605c3e75edb2f

Merge branch 'RAM-translation-generative-seeded' into develop

rrossajmcd committed 10 years ago
Unverified
b0ead529b70ad431b570629f3b6cf6a3fb25dd62

track protean changes

rrossajmcd committed 10 years ago
Unverified
d48893058218e151f51f1cc74832bf2930dfff49

add generative information to codex

rrossajmcd committed 10 years ago
Unverified
6c021b2a9058a8d2935e0a615546da5fe294c9be

conform with Ring Compojure spec req-params -> query-params

rrossajmcd committed 10 years ago
Unverified
3d336cfa00cfabafb90b6cffc59c27a6935054e8

upgrade beers codex to handle multimethods

rrossajmcd committed 11 years ago
Unverified
f9690caff60509b1fd8da67bebd126a9e69ad29c

improve yeast and starch values

committed 11 years ago

README

The README file for this repository.

Protean Beers

A contrived sample API and webapp built with Clojure. Figures out ingredients for different beverages and lets you brew them :-)

The idea is to illustrate some ideas in building a 'regular' API, and the benefits this can yield. The webapp is not as simple as it could be as it employs some componentisation (decoupling) etc.

Will eventually be loosely based on Wikipedia Brewing.

Includes a Protean codex beers.edn demonstrating how to simulate and automatically integration test with Protean.

Usage

Starting the service

lein deps
lein run

runs on port 3002

Accessing resources

List starches:

curl -v -H 'Authorization: XYZBearer token' 'http://localhost:3002/beers/starches'

List yeasts:

curl -v -H 'Authorization: XYZBearer token' 'http://localhost:3002/beers/yeasts'

List flavourings:

curl -v -H 'Authorization: XYZBearer token' 'http://localhost:3002/beers/flavourings'

Get a starch source for ale beverage type:

curl -v -H 'Authorization: XYZBearer token' 'http://localhost:3002/beers/starches/pick?drink=ale'

Get a yeast for lager beverage type:

curl -v -H 'Authorization: XYZBearer token' 'http://localhost:3002/beers/yeasts/pick?drink=lager'

Get a flavour for ale beverage type:

curl -v -H 'Authorization: XYZBearer token' 'http://localhost:3002/beers/flavourings/pick?drink=lager'

Brew a beverage:

curl -v -X POST -H 'Authorization: XYZBearer token' -H 'Content-Type: application/json' -H 'Content-type: application/json' --data '{"starch":"/starches/malted-grain","yeast":"/yeasts/saccharomyces-cerevisiae","flavouring":"/flavourings/golding-hops"}' 'http://localhost:3002/beers/brew'

Integration testing the service simulation

N.B. The following merely aggregates the responses from hitting the simulated resources - nothing too useful at the time of writing.

curl -v -X POST -H "Content-Type: application/json" --data '{"locs":["beers"],"seed":{"drink":"ale"}}' 'http://localhost:3001/test'

Automatically integration testing the service

The below will automatically (incrementally) integration test the service. Host and port should be configured to point to an instance of Protean (admin port). At the time of writing this is a naive test mechanism which produces a JSON payload... JUnit output is in the pipeline.

Testing specific resources:

curl -v -X POST -H "Content-Type: application/json" --data '{"port":3002,"locs":["beers token starches/pick yeasts/pick flavourings/pick"],"seed":{"drink":"ale"}}' 'http://localhost:3001/test'

Testing the entire service:

curl -v -X POST -H "Content-Type: application/json" --data '{"port":3002,"locs":["beers"],"seed":{"drink":"ale"}}' 'http://localhost:3001/test'

Contributing

All contributions ideas/pull requests/bug reports are welcome, we hope you find it useful.

License

Protean is licensed with Apache License v2.0.