This project is a Spring Boot 3 application using Java 17. It includes a REST API for managing albums.
-
Root Directory:
pom.xml
: Contains the project setup for a Spring Boot 3 application.
-
Java Package:
examples.azure.containerappsalbumapi
located atsrc/main/java/examples/azure/containerappsalbumapi/
AlbumController.java
: A REST controller with specified endpoints.Album.java
: An entity class representing an album.
-
Album.java
has the following fields:int id
String title
String artist
double price
String imageUrl
-
AlbumController.java
includes the following endpoints:- GET
/
: Returns an HTML string with a welcome message and a list of available endpoints. - GET
/albums
: Accepts optional query parametersowner
(String),lowPrice
(Double), andhighPrice
(Double). Filters albums based on these parameters. - GET
/albums/{id}/owner
: Returns the owner of the album with the specified ID.
- GET
-
Private Helper Methods in
AlbumController
:filterAlbumsByOwner(String owner, List<Album> albums)
: Filters albums by owner.filterAlbumsByPrice(Double lowPrice, Double highPrice, List<Album> albums)
: Filters albums by price range.loadAllAlbums()
: Loads a predefined list of albums.
To run the project, follow these steps:
-
Ensure you have Java 17 installed on your machine.
-
Clone the repository.
-
Navigate to the root directory of the project.
-
Run the following command to start the Spring Boot application:
./mvnw spring-boot:run
-
The application will start, and you can access the API at
https://localhost:8080
.
- GET
/
: Returns a welcome message and a list of available endpoints. - GET
/albums
: Retrieves a list of albums with optional filtering by owner and price range. - GET
/albums/{id}/owner
: Retrieves the owner of the album with the specified ID.