我正在寻找一个选项如何从路线中删除{one?} / {two?} / {three?} / {four?} / {five?}这个。 这会自动添加到每个路线中 像
public static void main(String[] args) throws Exception {
//Parse the args
if (args.length != 1) {
System.err.println("Main()/: String to MD5 digest should be first parameter\n");
System.out.println("Main()/: Require now a clear password with 4 char :");
sc = new Scanner(System.in);
in = sc.nextLine();
force = 2;
}
else{
in = args[0];
force = Integer.parseInt(args[1]);
}
//Set the count of Breakers
count=force;
//Make the hash
Hashmaker hm = new Hashmaker(in,"Hashmaker");
hm.start();
System.out.println("Main()/: Managing the breakers will start !");
//Get the hash
hash=hm.getHash();
//Manage the Breakers
f = new File(count);
for(int i=0; i<count;i++){
Hashbreaker hb = new Hashbreaker(hash,"HashBreaker"+i);
f.enfiler(hb);
hb.start();
}
}
在使用以下路线的路线档案中
v1/webapi/login/{one?}/{two?}/{three?}/{four?}/{five?}
v1/webapi/logout/{one?}/{two?}/{three?}/{four?}/{five?}
任何人都可以遇到同样的问题吗?
答案 0 :(得分:0)
简短回答是 - 您无法将其删除。此方法https://github.com/laravel/framework/blob/5.2/src/Illuminate/Routing/ControllerInspector.php#L132添加那些通配符参数。
摆脱它的唯一方法是重写Router
并使用你自己的ControllerInspector
,但这是毫无意义的,很难实现。
<强>更新强>
但如果你真的想这样做,那就有一个hacky解决方案:
foreach (\Route::getRoutes() as $route) {
$route->setUri(preg_replace('%\{one\?\}/\{two\?\}/\{three\?\}/\{four\?\}/\{five\?\}$%', '',
$route->getUri()));
}
将此代码放入RouteServiceProvider.php
boot
方法。