# poc-spring-boot-dynamic-controller **Repository Path**: a998151/poc-spring-boot-dynamic-controller ## Basic Information - **Project Name**: poc-spring-boot-dynamic-controller - **Description**: Simple POC/draft of how to add a REST controller in Spring Boot at runtime - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-10 - **Last Updated**: 2022-05-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 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: ```bash ./mvnw spring-boot:run ``` Fetch all users: ```bash 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](https://bytebuddy.net) in [UserDynamicControllerGenerator.java](https://github.com/tsarenkotxt/poc-spring-boot-dynamic-controller/blob/master/src/main/java/com/example/dynamic/controller/demo/UserDynamicControllerGenerator.java) 2. The Controller registered to Spring MVC by [RequestMappingHandlerMapping](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.html) in [UserDynamicControllerRegister.java](https://github.com/tsarenkotxt/poc-spring-boot-dynamic-controller/blob/master/src/main/java/com/example/dynamic/controller/demo/UserDynamicControllerRegister.java)