-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from shiyindaxiaojie/feature
fixed curator version
- Loading branch information
Showing
3 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ | |
|
||
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; | ||
import com.alibaba.csp.sentinel.slots.block.BlockException; | ||
import org.springframework.http.MediaType; | ||
import org.ylzl.eden.spring.framework.json.support.JSONHelper; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.ylzl.eden.spring.framework.web.util.ServletUtils; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
@@ -30,12 +30,14 @@ | |
* @author <a href="mailto:[email protected]">gyl</a> | ||
* @since 2.4.13 | ||
*/ | ||
@Slf4j | ||
public class CustomBlockExceptionHandler implements BlockExceptionHandler { | ||
|
||
@Override | ||
public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception { | ||
Object body = BlockResponseBuilder.buildResponse(e); | ||
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
response.getWriter().write(JSONHelper.json().toJSONString(body)); | ||
String body = BlockResponseBuilder.buildResponse(e).toString(); | ||
log.debug("Trigger sentinel block response: {}", body); | ||
response.setContentType(ServletUtils.APPLICATION_JSON_UTF8_VALUE); | ||
response.getWriter().write(body); | ||
} | ||
} |