callicoder / spring-security-react-ant-design-polls-app

Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
https://www.callicoder.com/spring-boot-spring-security-jwt-mysql-react-app-part-1/
1.77k stars 1.07k forks source link

What do these lines of code do? #28

Open gistmap opened 4 years ago

gistmap commented 4 years ago

hello, I can't understand what these line of code do.

URI location = ServletUriComponentsBuilder
                .fromCurrentContextPath().path("/users/{username}")
                .buildAndExpand(result.getUsername()).toUri();

return ResponseEntity.created(location).body(new ApiResponse(true, "User registered successfully"));
jhefreyzz commented 4 years ago

Hello, it means it will return 201 HTTP response and sets the Location in this case location in the response headers