本文整理匯總了Java中com.netflix.zuul.context.RequestContext.getCurrentContext方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestContext.getCurrentContext方法的具體用法?Java RequestContext.getCurrentContext怎麽用?Java RequestContext.getCurrentContext使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.netflix.zuul.context.RequestContext的用法示例。
在下文中一共展示了RequestContext.getCurrentContext方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: run
點讚 4
import com.netflix.zuul.context.RequestContext; //導入方法依賴的package包/類
@Override
public Object run() {
try {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletResponse response = ctx.getResponse();
if (!rateLimiter.tryAcquire()) {
HttpStatus httpStatus = HttpStatus.TOO_MANY_REQUESTS;
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
response.setStatus(httpStatus.value());
ctx.setResponseStatusCode(httpStatus.value());
ctx.setSendZuulResponse(false);
}
} catch (Exception e) {
ReflectionUtils.rethrowRuntimeException(e);
}
return null;
}
開發者ID:kenly333,項目名稱:service-hive,代碼行數:21,
示例2: run_on_valid_response
點讚 3
import com.netflix.zuul.context.RequestContext; //導入方法依賴的package包/類
@Test
public void run_on_valid_response() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/service1" + DEFAULT_URL);
RequestContext context = RequestContext.getCurrentContext();
context.setRequest(request);
MockHttpServletResponse response = new MockHttpServletResponse();
context.setResponseGZipped(false);
context.setResponse(response);
InputStream in = IOUtils.toInputStream("{\"basePath\":\"/\"}", StandardCharsets.UTF_8);
context.setResponseDataStream(in);
filter.run();
assertEquals("UTF-8", response.getCharacterEncoding());
assertEquals("{\"basePath\":\"/service1\"}", context.getResponseBody());
}
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:19,
示例3: run
點讚 3
import com.netflix.zuul.context.RequestContext; //導入方法依賴的package包/類
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
log.info(String.format("%s request to %s", request.getMethod(), request.getRequestURL().toString()));
Object accessToken = request.getParameter("accessToken");
if(accessToken == null)