yz
2021-01-16 309c3281b5a2ca4acfc6fd46e333eff2f2c5d206
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
27
package cc.mrbird.febs.gateway.common.controller;
 
import cc.mrbird.febs.common.core.entity.FebsResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
 
/**
 * @author MrBird
 */
@Slf4j
@RestController
public class FallbackController {
 
    @RequestMapping("fallback/{name}")
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public Mono<FebsResponse> systemFallback(@PathVariable String name) {
        String response = "服务访问超时,请稍后再试";
        log.error("{},目标微服务:{}", response, name);
        return Mono.just(new FebsResponse().message(response));
    }
 
}