11package com.grepp.quizy.api
22
3- import com.grepp.quizy.common.api.ApiResponse
4- import org.springframework.http.HttpStatus
5- import org.springframework.http.ResponseEntity
3+ import com.grepp.quizy.exception.CustomCircuitBreakerException
64import org.springframework.web.bind.annotation.GetMapping
75import org.springframework.web.bind.annotation.RequestMapping
86import org.springframework.web.bind.annotation.RestController
@@ -11,42 +9,27 @@ import org.springframework.web.bind.annotation.RestController
119@RequestMapping(" /fallback" )
1210class GatewayFallbackController {
1311 @GetMapping(" /user" )
14- fun userServiceFallback (): ResponseEntity <ApiResponse <Unit >> {
15- return ResponseEntity
16- .status(HttpStatus .SERVICE_UNAVAILABLE )
17- .body(ApiResponse .error(HttpStatus .SERVICE_UNAVAILABLE .name, " User service is temporarily unavailable" ))
12+ fun userServiceFallback () {
13+ throw CustomCircuitBreakerException .UserServiceUnavailableException
1814 }
1915
2016 @GetMapping(" /quiz" )
21- fun quizServiceFallback (): ResponseEntity <ApiResponse <Unit >> {
22- return ResponseEntity
23- .status(HttpStatus .SERVICE_UNAVAILABLE )
24- .body(ApiResponse .error(HttpStatus .SERVICE_UNAVAILABLE .name, " Quiz service is temporarily unavailable" ))
17+ fun quizServiceFallback () {
18+ throw CustomCircuitBreakerException .QuizServiceUnavailableException
2519 }
2620
2721 @GetMapping(" /game" )
28- fun gameServiceFallback (): ResponseEntity <ApiResponse <Unit >> {
29- return ResponseEntity
30- .status(HttpStatus .SERVICE_UNAVAILABLE )
31- .body(ApiResponse .error(HttpStatus .SERVICE_UNAVAILABLE .name, " Game service is temporarily unavailable" ))
22+ fun gameServiceFallback () {
23+ throw CustomCircuitBreakerException .GameServiceUnavailableException
3224 }
3325
3426 @GetMapping(" /ws" )
35- fun webSocketServiceFallback (): ResponseEntity <ApiResponse <Unit >> {
36- return ResponseEntity
37- .status(HttpStatus .SERVICE_UNAVAILABLE )
38- .body(
39- ApiResponse .error(
40- HttpStatus .SERVICE_UNAVAILABLE .name,
41- " Game webSocket service is temporarily unavailable"
42- )
43- )
27+ fun webSocketServiceFallback () {
28+ throw CustomCircuitBreakerException .WsUnavailableException
4429 }
4530
4631 @GetMapping(" /matching" )
47- fun matchingServiceFallback (): ResponseEntity <ApiResponse <Unit >> {
48- return ResponseEntity
49- .status(HttpStatus .SERVICE_UNAVAILABLE )
50- .body(ApiResponse .error(HttpStatus .SERVICE_UNAVAILABLE .name, " Matching service is temporarily unavailable" ))
32+ fun matchingServiceFallback () {
33+ throw CustomCircuitBreakerException .MatchingServiceUnavailableException
5134 }
5235}
0 commit comments