This is a simple POC/draft of how to add a REST controller in Spring Boot at runtime
Run the Spring Boot application:
./mvnw spring-boot:run
Fetch all users:
curl http://localhost:8080/users/
Simple user
REST API:
URL | HttpMethod | RequestParam | PathVariable | RequestBody | ResponseBody | Description |
---|---|---|---|---|---|---|
/users/ | GET | List(User) | get all | |||
/users | GET | id | User | get by id | ||
/users | POST | User | save | |||
/users | PUT | id | User | update | ||
/users | PATCH | id, nickName | update nickName | |||
/users/{id} | DELETE | id | delete |
- The Controller generated by Byte Buddy in UserDynamicControllerGenerator.java
- The Controller registered to Spring MVC by RequestMappingHandlerMapping in UserDynamicControllerRegister.java