Skip to content

Commit 7983a41

Browse files
committed
Use a more concise way to set ResponseEntity status code
1 parent 6a68383 commit 7983a41

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/main/kotlin/fi/hsl/jore4/hastus/api/ExportController.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import fi.hsl.jore4.hastus.Constants.MIME_TYPE_CSV
55
import fi.hsl.jore4.hastus.api.util.HastusApiErrorType
66
import fi.hsl.jore4.hastus.service.exporting.ExportService
77
import mu.KotlinLogging
8-
import org.springframework.http.HttpStatus
98
import org.springframework.http.MediaType
109
import org.springframework.http.ResponseEntity
1110
import org.springframework.web.bind.annotation.ExceptionHandler
@@ -59,7 +58,7 @@ class ExportController(
5958
LOGGER.info { "Routes request took $elapsed" }
6059

6160
return ResponseEntity
62-
.status(HttpStatus.OK)
61+
.ok()
6362
.body(result)
6463
}
6564

@@ -76,7 +75,7 @@ class ExportController(
7675
LOGGER.error(ex.stackTraceToString())
7776

7877
ResponseEntity
79-
.status(HttpStatus.INTERNAL_SERVER_ERROR)
78+
.internalServerError()
8079
.body(ExportRoutesErrorResponse(HastusApiErrorType.from(ex), ex.message))
8180
}
8281
}

src/main/kotlin/fi/hsl/jore4/hastus/api/ImportController.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import fi.hsl.jore4.hastus.Constants.MIME_TYPE_CSV
44
import fi.hsl.jore4.hastus.api.util.HastusApiErrorType
55
import fi.hsl.jore4.hastus.service.importing.ImportService
66
import mu.KotlinLogging
7-
import org.springframework.http.HttpStatus
87
import org.springframework.http.ResponseEntity
98
import org.springframework.web.bind.annotation.ExceptionHandler
109
import org.springframework.web.bind.annotation.PostMapping
@@ -74,7 +73,7 @@ class ImportController(
7473
LOGGER.error(ex.stackTraceToString())
7574

7675
ResponseEntity
77-
.status(HttpStatus.INTERNAL_SERVER_ERROR)
76+
.internalServerError()
7877
.body(ImportTimetablesFailureResult(HastusApiErrorType.from(ex), ex.message))
7978
}
8079
}

0 commit comments

Comments
 (0)