Skip to content

Commit 5f1d51b

Browse files
committed
Refactoring
1 parent f65c70a commit 5f1d51b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/kotlin/no/nav/klage/document/api/DocumentController.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*
1212
import java.util.*
1313

1414
@RestController
15+
@RequestMapping("/documents")
1516
class DocumentController(
1617
private val documentService: DocumentService,
1718
private val commentService: CommentService
@@ -22,21 +23,21 @@ class DocumentController(
2223
private val logger = getLogger(javaClass.enclosingClass)
2324
}
2425

25-
@PostMapping("/documents")
26+
@PostMapping("/")
2627
fun createDocument(
2728
@RequestBody json: String
2829
): DocumentView {
2930
logger.debug("createDocument: received json: {}", json)
3031
return mapToDocumentView(documentService.createDocument(json))
3132
}
3233

33-
@GetMapping("/documents/{documentId}")
34+
@GetMapping("/{documentId}")
3435
fun getDocument(@PathVariable("documentId") documentId: UUID): DocumentView {
3536
logger.debug("getDocument")
3637
return mapToDocumentView(documentService.getDocument(documentId))
3738
}
3839

39-
@PostMapping("/documents/{documentId}/comments")
40+
@PostMapping("/{documentId}/comments")
4041
fun createComment(
4142
@PathVariable("documentId") documentId: UUID,
4243
@RequestBody commentInput: CommentInput
@@ -52,15 +53,15 @@ class DocumentController(
5253
)
5354
}
5455

55-
@GetMapping("/documents/{documentId}/comments")
56+
@GetMapping("/{documentId}/comments")
5657
fun getAllCommentsWithPossibleThreads(
5758
@PathVariable("documentId") documentId: UUID
5859
): List<CommentView> {
5960
logger.debug("getAllCommentsWithPossibleThreads")
6061
return commentService.getComments(documentId).map { mapCommentToView(it) }
6162
}
6263

63-
@PostMapping("/documents/{documentId}/comments/{commentId}")
64+
@PostMapping("/{documentId}/comments/{commentId}")
6465
fun replyToComment(
6566
@PathVariable("documentId") documentId: UUID,
6667
@PathVariable("commentId") commentId: UUID,
@@ -78,7 +79,7 @@ class DocumentController(
7879
)
7980
}
8081

81-
@GetMapping("/documents/{documentId}/comments/{commentId}")
82+
@GetMapping("/{documentId}/comments/{commentId}")
8283
fun getCommentWithPossibleThread(
8384
@PathVariable("documentId") documentId: UUID,
8485
@PathVariable("commentId") commentId: UUID

0 commit comments

Comments
 (0)