Laravel 4中的RESTful和Resource控制器是有限的,RESTful方法名称必须以get,put,post,patch,delete结束,资源控制器必须以索引,创建,存储,显示编辑,更新,销毁结束。我的问题是Laravel 5是否施加了相同的限制?
答案 0 :(得分:2)
本地,是,它确实。阅读here。但如果你想要不同的东西,我会给你一个诀窍来做到这一点。首先,您可以创建自己的 WARN o.r.server.net.rtmp.RTMPConnManager - Exception creating connection
org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ScheduledThreadPoolExecutor@1a44651[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]] did not accept task: org.red5.server.net.rtmp.RTMPConnection$WaitForHandshakeTask@1345e03
at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.execute(ThreadPoolTaskScheduler.java:226) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.red5.server.net.rtmp.RTMPConnection.startWaitForHandshake(RTMPConnection.java:423) ~[red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPConnManager.createConnection(RTMPConnManager.java:176) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPConnManager.createConnection(RTMPConnManager.java:56) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPMinaIoHandler.createRTMPMinaConnection(RTMPMinaIoHandler.java:297) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPMinaIoHandler.sessionCreated(RTMPMinaIoHandler.java:61) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionCreated(DefaultIoFilterChain.java:772) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:459) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$700(DefaultIoFilterChain.java:48) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionCreated(DefaultIoFilterChain.java:913) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.IoFilterAdapter.sessionCreated(IoFilterAdapter.java:74) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:459) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionCreated(DefaultIoFilterChain.java:452) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionCreated(IoServiceListenerSupport.java:211) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.addNow(AbstractPollingIoProcessor.java:542) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.handleNewSessions(AbstractPollingIoProcessor.java:510) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:68) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1120) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.10-SNAPSHOT.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_20]
Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@12e54e rejected from java.util.concurrent.ScheduledThreadPoolExecutor@1a44651[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) ~[na:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823) [na:1.8.0_20]
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326) ~[na:1.8.0_20]
at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533) ~[na:1.8.0_20]
at java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:622) ~[na:1.8.0_20]
at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.execute(ThreadPoolTaskScheduler.java:223) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
... 21 common frames omitted
2016-02-11 15:06:20,728 [NioProcessor-4] INFO o.r.server.net.rtmp.RTMPConnection - Rejected message: Packet [[header data type=20, channel=3, timer=0], [message timestamp=0]] on AJBBLZP7WF0FT
2016-02-11 15:06:30,651 [NioProcessor-5] WARN o.r.server.net.rtmp.RTMPConnManager - Exception creating connection
org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ScheduledThreadPoolExecutor@1a44651[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]] did not accept task: org.red5.server.net.rtmp.RTMPConnection$WaitForHandshakeTask@171285a
at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.execute(ThreadPoolTaskScheduler.java:226) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.red5.server.net.rtmp.RTMPConnection.startWaitForHandshake(RTMPConnection.java:423) ~[red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPConnManager.createConnection(RTMPConnManager.java:176) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPConnManager.createConnection(RTMPConnManager.java:56) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPMinaIoHandler.createRTMPMinaConnection(RTMPMinaIoHandler.java:297) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPMinaIoHandler.sessionCreated(RTMPMinaIoHandler.java:61) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionCreated(DefaultIoFilterChain.java:772) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:459) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$700(DefaultIoFilterChain.java:48) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionCreated(DefaultIoFilterChain.java:913) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.IoFilterAdapter.sessionCreated(IoFilterAdapter.java:74) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:459) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionCreated(DefaultIoFilterChain.java:452) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionCreated(IoServiceListenerSupport.java:211) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.addNow(AbstractPollingIoProcessor.java:542) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.handleNewSessions(AbstractPollingIoProcessor.java:510) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:68) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1120) [mina-core-2.0.10-SNAPSHOT.jar:na]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.10-SNAPSHOT.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_20]
Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@7794fd rejected from java.util.concurrent.ScheduledThreadPoolExecutor@1a44651[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) ~[na:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823) [na:1.8.0_20]
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326) ~[na:1.8.0_20]
at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533) ~[na:1.8.0_20]
at java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:622) ~[na:1.8.0_20]
at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.execute(ThreadPoolTaskScheduler.java:223) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
... 21 common frames omitted
。我的[位于ResourceRegistrar
]:
app/Routing/ResourceRegistrar.php
然后在您的服务提供商中注册您自己的namespace App\Routing;
use Illuminate\Routing\ResourceRegistrar as BaseRegistrar;
class ResourceRegistrar extends BaseRegistrar
{
}
:
RouteRegistrar
注意:我通过
$this->app->bind('Illuminate\Routing\ResourceRegistrar', 'App\Routing\ResourceRegistrar');
方法在RouteRegistrar
注册我自己的App\Providers\AppServiceProvider
。
我在register
中添加了我自己的资源控制器:
routes.php
所以,我应该有一个Route::resource('photo', 'PhotoController');
来处理这个请求。
我们知道,PhotoController
对'/ photo'的请求将由GET
方法处理,将PhotoController@index
操作修改为photo:index
操作,修改您的{ {1}}这样的事情:
photo:root
现在ResourceRegistrar
对'/ photo'的请求将由namespace App\Routing;
use Illuminate\Routing\ResourceRegistrar as BaseRegistrar;
class ResourceRegistrar extends BaseRegistrar
{
protected function addResourceIndex($name, $base, $controller, $options)
{
$uri = $this->getResourceUri($name);
$action = $this->getResourceAction($name, $controller, 'root', $options);
return $this->router->get($uri, $action);
}
}
方法处理。
GET
请参阅PhotoController@root
here的基本代码。