A simple Spring Boot REST API demonstrating basic endpoint creation, path variables, request parameters, and logging functionality.
This project is a submission for Week 5 of the PAF (Programming Application Framework) course. It implements a basic RESTful web service using Spring Boot that showcases fundamental concepts like request handling, parameter binding, and logging.
- Root Endpoint: Basic health check endpoint
- Greeting Endpoints: Multiple endpoints demonstrating different parameter handling
- Simple greeting without parameters
- Personalized greeting with path variables
- Custom messages using query parameters
- Logging: Comprehensive logging for all endpoint access
- Java 17+
- Spring Boot 3.x
- Maven
- SLF4J for logging
src/main/java/org/example/paf_w5_submission/
βββ PafW5SubmissionApplication.java # Main application class
βββ GreetingController.java # REST Controller with endpoints
- URL:
/ - Method:
GET - Response:
"Your Spring Boot Application is Alive.!" - Logs: Records access to root endpoint
- URL:
/greet - Method:
GET - Response:
"Welcome to Spring Boot!" - Logs: Records access to greet endpoint
- URL:
/greet/{name} - Method:
GET - Path Variable:
name- Person's name - Query Parameter:
message(optional) - Custom message - Response Examples:
- Without custom message:
"Hello John! Welcome to Spring Boot!" - With custom message:
"Hello John! Have a great day!"
- Without custom message:
- Logs: Records name and any custom message provided
- Java Development Kit (JDK) 17 or later
- Maven 3.6+
- Your favorite IDE (IntelliJ IDEA, Eclipse, VS Code)
- Clone the repository
git clone https://github.com/dyneth02/paf-w5-submission.git
cd paf-w5-submission
- Build the project
mvn clean install
- Run the application
mvn spring-boot:run
Or run the main class `PafW5SubmissionApplication` from your IDE.
-
Access the application
- Application will start on
http://localhost:8080
- Application will start on
Test the endpoints using your browser or tools like curl/Postman:
# Root endpoint
curl http://localhost:8080/
# Basic greeting
curl http://localhost:8080/greet
# Personalized greeting without message
curl http://localhost:8080/greet/John
# Personalized greeting with custom message
curl http://localhost:8080/greet/John?message=Have%20a%20nice%20day!
The application logs all requests with timestamps:
INFO GreetingController: Root endpoint accessed
INFO GreetingController: Greet endpoint accessed
INFO GreetingController: Greeting request received for name: John
INFO GreetingController: Custom message provided: Have a nice day!
You can test the endpoints manually using:
- Web browser for GET requests
- Postman/Insomnia for API testing
- curl commands in terminal
This is a course submission project. Feel free to fork and experiment with the code.
This project is for educational purposes as part of the PAF course.
- PAF Course Instructors
- Spring Boot Documentation
- Open source community
Author: Dineth Hirusha
Course: PAF (Programming Application Framework)
Week: 5
Submission: REST API Implementation