Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit ecbb01c

Browse files
authored
Merge pull request #236 from swooletw/develop
Develop
2 parents c266951 + c23a573 commit ecbb01c

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

src/HttpServiceProvider.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
use SwooleTW\Http\Helpers\FW;
66
use Illuminate\Queue\QueueManager;
7-
use Illuminate\Contracts\Http\Kernel;
87
use Swoole\Http\Server as HttpServer;
98
use Illuminate\Support\ServiceProvider;
10-
use SwooleTW\Http\Middleware\AccessLog;
119
use SwooleTW\Http\Server\Facades\Server;
1210
use Illuminate\Database\DatabaseManager;
1311
use SwooleTW\Http\Coroutine\MySqlConnection;
@@ -62,11 +60,18 @@ public function register()
6260
abstract protected function registerManager();
6361

6462
/**
65-
* Boot routes.
63+
* Boot websocket routes.
6664
*
6765
* @return void
6866
*/
69-
abstract protected function bootRoutes();
67+
abstract protected function bootWebsocketRoutes();
68+
69+
/**
70+
* Register access log middleware to container.
71+
*
72+
* @return void
73+
*/
74+
abstract protected function pushAccessLogMiddleware();
7075

7176
/**
7277
* Boot the service provider.
@@ -88,7 +93,7 @@ public function boot()
8893
}
8994

9095
if ($config->get('swoole_http.server.access_log')) {
91-
$this->app->make(Kernel::class)->pushMiddleware(AccessLog::class);
96+
$this->pushAccessLogMiddleware();
9297
}
9398
}
9499

src/LaravelServiceProvider.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace SwooleTW\Http;
44

55
use SwooleTW\Http\Server\Manager;
6+
use Illuminate\Contracts\Http\Kernel;
7+
use SwooleTW\Http\Middleware\AccessLog;
68

79
/**
810
* @codeCoverageIgnore
@@ -24,12 +26,22 @@ protected function registerManager()
2426
}
2527

2628
/**
27-
* Boot routes.
29+
* Boot websocket routes.
2830
*
2931
* @return void
3032
*/
31-
protected function bootRoutes()
33+
protected function bootWebsocketRoutes()
3234
{
3335
require __DIR__ . '/../routes/laravel_routes.php';
3436
}
37+
38+
/**
39+
* Register access log middleware to container.
40+
*
41+
* @return void
42+
*/
43+
protected function pushAccessLogMiddleware()
44+
{
45+
$this->app->make(Kernel::class)->pushMiddleware(AccessLog::class);
46+
}
3547
}

src/LumenServiceProvider.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SwooleTW\Http;
44

55
use SwooleTW\Http\Server\Manager;
6+
use SwooleTW\Http\Middleware\AccessLog;
67

78
/**
89
* @codeCoverageIgnore
@@ -24,14 +25,15 @@ protected function registerManager()
2425
}
2526

2627
/**
27-
* Boot routes.
28+
* Boot websocket routes.
2829
*
2930
* @return void
3031
*/
31-
protected function bootRoutes()
32+
protected function bootWebsocketRoutes()
3233
{
3334
$app = $this->app;
3435

36+
// router only exists after lumen 5.5
3537
if (property_exists($app, 'router')) {
3638
$app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function ($app) {
3739
require __DIR__ . '/../routes/lumen_routes.php';
@@ -42,4 +44,14 @@ protected function bootRoutes()
4244
});
4345
}
4446
}
47+
48+
/**
49+
* Register access log middleware to container.
50+
*
51+
* @return void
52+
*/
53+
protected function pushAccessLogMiddleware()
54+
{
55+
$this->app->middleware(AccessLog::class);
56+
}
4557
}

0 commit comments

Comments
 (0)