我试图在VS C#2010 Express中使用'async'和'await'关键字,但我似乎无法使用此关键字.但是,当我在VS C#2012 Professional中使用此关键字时,可以使用它.我必须下载使用它吗?
我试图用来Zuul将呼叫重定向到其他地方的下游系统。在api重定向中,我需要在Header中添加必要的数据,以接收要处理的重定向。我似乎无法让下游系统检测到此数据。附件是我的代码。我使用Zuul从Edgware.SR3, Spring Boot 1.5.12
Zuul过滤器
@Component
public class RouteFilter extends ZuulFilter{
@Override
public Object run() {
//Testing to add header
context.getRequest().getParameterMap().put("api", new String[]{"api"});
context.getResponse().setHeader("api", api);
context.addZuulResponseHeader("api", "api");
context.addZuulRequestHeader("api", "api");
context.setSendZuulResponse(false);
context.put(FORWARD_TO_KEY, redirect_urls.get(key));
context.setResponseStatusCode(HttpStatus.SC_TEMPORARY_REDIRECT);
context.getResponse().sendRedirect(redirect_urls.get(key));
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
重定向服务代码
@RequestMapping(value = "/forward")
public ResponseEntity<String> forwardToMe(@RequestHeader(required = true, name = "api")String api){
return new ResponseEntity<String>("Hi",HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
邮递员中收到错误
{“ timestamp”:1524737817729,“ status”:400,“ error”:“ Bad Request”,“ exception”:“ org.springframework.web.bind.ServletRequestBindingException”,“ message”:“缺少请求标头'api'类型为String的方法参数“,” path“:” / forward“}
我试图将这个多维数组安排为升序或降序.但是,我需要第1列和第2列之间的关系仍然在一起(意味着我需要例如数组[0,1]和数组[0,2]的数据在一起或以某种方式相关.这是我现在的代码.
int[,] time = new int[5,2]{{0,4},{1,5},{5,10},{3,4},{0,2}};
var sorted = from x in Enumerable.Range(0, time.GetLength(0))
from y in Enumerable.Range(0, time.GetLength(1))
select new{
X = x,
Y = y,
Value = time[x,y]
}into point
orderby point.Value descending
select point;
Run Code Online (Sandbox Code Playgroud)
这有效,但它将我的所有数据分开.有没有办法在保持第1列和第2列的关系的同时对它们进行排序?