Created
March 22, 2019 16:09
-
-
Save Enforcer/24b928471ff79d6a2aac6bbbdc9b7418 to your computer and use it in GitHub Desktop.
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
defmodule Wallets.Router do | |
use Plug.Router | |
plug(:match) | |
plug(:fetch_query_params) | |
plug(:dispatch) | |
get "/balance" do | |
send_resp(conn, 200, "Not implemented") | |
end | |
# Example: curl -X POST 'http://localhost:8080/credit?owner_id=1¤cy_id=3&amount=100' | |
post "/credit" do | |
IO.inspect(conn.query_params) | |
owner_id = conn.query_params["owner_id"] | |
currency_id = conn.query_params["currency_id"] | |
amount = conn.query_params["amount"] | |
send_resp(conn, 200, "Credited #{amount} of #{currency_id} to #{owner_id}") | |
end | |
post("/debit", do: send_resp(conn, 200, "Not implemented")) | |
match(_, do: send_resp(conn, 404, "Not Found")) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment