我试图在REST API上启用版本控制,其中版本在标题中指定为"api-version":2.
根据这个教程,我只需要创建
VersionConstraint : IHttpRouteConstraint
和
VersionedRoute: RouteFactoryAttribute
用法是将[VersionedRoute("api/controllerName", 2)]属性应用于控制器,这是为特定版本设计的(例如,在这种情况下为版本2).
这一切都很好,但不幸的是,它全部在MVC5中,而我正在使用MVC6.因此,RouteFactoryAttribute并IHttpRouteConstraint不能正常工作.
我设法找到IRouteConstraint替换IHttpRouteConstraint(希望它可以工作),但我找不到替代品RouteFactoryAttribute.
如果有人可以使用MVC 6提供这样的示例,或者至少提到正确的类(理想情况下使用命名空间),我需要继承吗?
.net asp.net-web-api asp.net-core-mvc api-versioning asp.net-core
我在运行Ubuntu 15.10的虚拟机上为Guest OS设置了一个GraphHopper的本地服务器,用于导航/路由.
要初始化服务器,需要指定以下命令(在终端中):,我将从此处java -jar graphhopper-web-0.5.0-with-dep.jar jetty.resourcebase=webapp config=config-example.properties osmreader.osm={osmFileName}.osm.pbf引用GHServerCommand.
我的问题:我可以将多个OSM文件加载到此服务器吗?
我试图以两种方式尝试这两种方式:
尝试1:
Server started on port 8989尝试2:
java -jar graphhopper-web-0.5.0-with-dep.jar jetty.resourcebase=webapp config=config-example.properties osmreader.osm={osmFileName1}.osm.pbf,{osmFileName2}.osm.pbf看到这两次尝试都不成功,我不确定这是否会起作用.有没有办法将多个osm.pbf文件加载到自托管的GraphHopper服务器?
我有一个GraphHopper路由引擎稳定版本0.5的问题
我可以在使用时获得指示vehicle=car,但这会因自行车和脚而失败.
以下是 GraphHopper地图上大约3分钟步行的示例:
这会在地图上产生结果,这很棒.
我在本地运行时使用了完全相同的坐标,以获取JSON数据,如下所示:
http://localhost:8989/routes?point=-33.916567%2C18.417914&point=-33.917584%2C18.418935&locale=en-US&vehicle=foot
这不会产生任何结果,而是返回以下响应:
{
"message": "Vehicle not supported: foot",
"hints": [{
"message": "Vehicle not supported: foot",
"details": "java.lang.IllegalArgumentException"
}]
}
Run Code Online (Sandbox Code Playgroud)
请注意,将车辆更改为汽车会产生结果!怎么能修好?
为了完整起见,这里是使用vehicle = car的样本请求和响应
{
"paths": [
{
"distance": 151.857,
"time": 18222,
"points_encoded": true,
"weight": 151.857451,
"instructions": [
{
"sign": 0,
"text": "Continue onto Hudson Street",
"time": 3782,
"distance": 31.517,
"interval": [
0,
1
]
},
{
"sign": -2,
"text": "Turn left onto …Run Code Online (Sandbox Code Playgroud) 有许多关于如何在以前的MVC版本中创建RouteConstraints的教程:
这如何与MVC6一起使用,特别是注册自定义路由约束,因此它可以用在ApiController动作的属性中?
我创建了一个名为NonEmptyGuid的自定义路由约束,它实际上只是确保将非空Guid用作GET操作的参数:
public class NonEmptyGuid : IRouteConstraint
{
public bool Match(HttpContext httpContext, IRouter route, string routeKey, IDictionary<string, object> values, RouteDirection routeDirection)
{
if (!values.ContainsKey(routeKey)) return false;
if (values[routeKey].ToString().Equals(Guid.Empty.ToString())) return false;
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
问题: 如何以及在何处为MVC6应用程序注册此自定义RouteConstraint (例如,在WebApi项目中).
c# asp.net asp.net-web-api-routing asp.net-core-mvc asp.net-core
是否有可能获得jsx由Parent组件包装的实际“原始”文本(例如 from props.children)?
鉴于此组件:
<Parent>
<Child name={'test'} />
</Parent>
Run Code Online (Sandbox Code Playgroud)
题:
在Parent.js,我可以用this.props.children(或其他任何东西)做任何事情来得到这个(最好是一个字符串):
输出:
"<Child name={'test'} />"
asp.net-core ×2
graphhopper ×2
navigation ×2
.net ×1
asp.net ×1
babeljs ×1
c# ×1
java ×1
jsx ×1
react-props ×1
reactjs ×1
routing ×1