tip
You can clone an already prepared sample which is built on top of spring boot using the spring boot starter library.
src/adapters/rest/UsersController.java
@RestController
@RequestMapping("/users")
public class UsersController {
private final AlbanoiGateway albanoiGateway;
public UsersController(AlbanoiGateway albanoiGateway) {
this.albanoiGateway = albanoiGateway;
}
@PostMapping
public ResponseEntity<User> createUser(@RequestBody CreateUserRequest createUserRequest) {
var createUserCommand = new CreateUserCommand();
createUserCommand.setUsername(createUserRequest.getUsername());
CommandResult<User> createUserResult = albanoiGateway.execute(createUserCommand, User.class);
return ResponseEntity.ok(createUserResult.getResult());
}
}
