A toy app to play with ETS and plug.
- Fetch dependencies. Run:
mix deps.get
- Start the server and interactive shell. Run
iex -S mix
- Commands to play with. Run from bash shell:
$ curl -i -XGET "http://localhost:4000/configs?path=/user/create"
$ curl -i -XPOST http://localhost:4000/user/create
$ curl -i -XPUT "http://localhost:4000/configs?path=/user/create&key=to&value=abc.com"
$ curl -i -XPUT "http://localhost:4000/configs?path=/user/create&key=new_key&value=new_value"
$ curl -i -XGET "http://localhost:4000/configs?path=/user/create"
- Excercises to try yourself:
- Make a plug that will add a header "X-My-Header" to a request. The value of header should be configurable and depend on the route in question (e.g. for "/user/create" it can be "Example 1", while for "/some/path/path" the header value can be "Example 2").