Skip to content

Commit

Permalink
Fix Location header (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmemarioss authored Jul 24, 2021
1 parent 3b0d709 commit 90794b0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ build/

##opeapi
.openapi-generator

#generated documentation
src/main/resources/templates/index.html
2 changes: 2 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ components:
content:
type: string
description: cordel text
published:
type: boolean
tags:
type: array
items:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>br.com.itsmemario</groupId>
<artifactId>ecordel</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.6.0-SNAPSHOT</version>
<name>e-cordel</name>
<description>e-reader for cordels</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package br.com.itsmemario.ecordel.author;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
Expand All @@ -31,6 +33,8 @@
@RequestMapping("authors")
public class AuthorController {

private final Logger logger = LoggerFactory.getLogger(AuthorController.class);

private AuthorService service;

public AuthorController(AuthorService service) {
Expand All @@ -43,9 +47,10 @@ public Page<AuthorView> getAll(Pageable pageable){
}

@PostMapping
public ResponseEntity<Author> newAuthor(@RequestBody @Valid AuthorDto author, UriComponentsBuilder uriBuilder){
service.save(author.toEntity());
URI uri = uriBuilder.path("/authors/{id}").buildAndExpand(author.getId()).toUri();
public ResponseEntity<Author> create(@RequestBody @Valid AuthorDto author, UriComponentsBuilder uriBuilder){
logger.info("request received for create author: {}", author);
var saved = service.save(author.toEntity());
URI uri = uriBuilder.path("/authors/{id}").buildAndExpand(saved.getId()).toUri();
return ResponseEntity.created(uri).build();
}
}

0 comments on commit 90794b0

Please sign in to comment.