-
Notifications
You must be signed in to change notification settings - Fork 53.3k
Expand file tree
/
Copy pathBookController.java
More file actions
26 lines (21 loc) · 846 Bytes
/
Copy pathBookController.java
File metadata and controls
26 lines (21 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.baeldung.httplogging;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.UUID;
@RestController
@RequestMapping("/api/books")
public class BookController {
@PostMapping
public ResponseEntity<BookCreatedResponse> create(@RequestBody CreateBookRequest request) {
BookCreatedResponse response = new BookCreatedResponse(
UUID.randomUUID(),
request.title(),
request.author()
);
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}
}