Skip to content

Latest commit

 

History

History
119 lines (80 loc) · 3 KB

README.md

File metadata and controls

119 lines (80 loc) · 3 KB

Geting Started

Checking out and building the project

git checkout [email protected]:pmanko2/BankingService.git

# Run from the ^ project root directory
gradlew build

Running the Micronaut microservice

You can either use Intellij to run Application.kt or use gradle from the root project directory

# from the project root directory
gradlew run

Sending requests to the API

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

Getting Account Balance

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'

Depositing Money

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
}'

Project Components

AccountController

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

Current Routes

  1. GET /accounts/:id

    Gets the current account balance information for the given bank account :id

  2. POST /accounts

    Accepts a new deposit to the bankAccount with the given POST body

    {
        "bankAccountId": 1,
        "amount": 20.0
    }

Micronaut Related Documentation

Micronaut 2.5.4 Documentation


Feature http-client documentation