/poc-spring-boot-dynamic-controller

Simple POC/draft of how to add a REST controller in Spring Boot at runtime

Primary LanguageJava

POC Spring Boot dynamic Controller

This is a simple POC/draft of how to add a REST controller in Spring Boot at runtime

Get started

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

How it's work ?

  1. The Controller generated by Byte Buddy in UserDynamicControllerGenerator.java
  2. The Controller registered to Spring MVC by RequestMappingHandlerMapping in UserDynamicControllerRegister.java