git checkout [email protected]:pmanko2/BankingService.git
# Run from the ^ project root directory
gradlew build
You can either use Intellij to run Application.kt
or use gradle from the root project directory
# from the project root directory
gradlew run
After successfully running your Micronaut project, you should see output that looks like this:
__ __ _ _
| \/ (_) ___ _ __ ___ _ __ __ _ _ _| |_
| |\/| | |/ __| '__/ _ \| '_ \ / _` | | | | __|
| | | | | (__| | | (_) | | | | (_| | |_| | |_
|_| |_|_|\___|_| \___/|_| |_|\__,_|\__,_|\__|
Micronaut (v2.5.4)
15:18:34.170 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 728ms. Server Running: http://localhost:8080
The url displayed after Server Running:
will be the base URL of your api service. You can make HTTP requests
to this URL in order to interact with your API.
You can use a request tool of your choice to make these requests. I would suggest downloading Postman which is a very useful tool we use at Favor to interact and test our APIs.
You can also use CURL from your command line: Curl Documentation
URL: GET http://localhost:8080/accounts/:id
The request to get the balance for bank account 1 would look like http://localhost:8080/accounts/1
# curl command
curl --location --request GET 'http://localhost:8080/accounts/1'
URL
POST http://localhost:8080/accounts
POST Body
Depositing $20 to bank account 1
{
"bankAccountId": 1,
"amount": 20.0
}
CURL Command
curl --location --request POST 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
"bankAccountId": 1,
"amount": 20.0
}'
This is where we define the different HTTP routes we want our API to handle. This class follows the principles outlined here https://docs.micronaut.io/latest/guide/index.html#routing
-
GET /accounts/:id
Gets the current account balance information for the given bank account :id
-
POST /accounts
Accepts a new deposit to the bankAccount with the given POST body
{ "bankAccountId": 1, "amount": 20.0 }