Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #236 from swooletw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
albertcht authored Mar 6, 2019
2 parents c266951 + c23a573 commit ecbb01c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/HttpServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

use SwooleTW\Http\Helpers\FW;
use Illuminate\Queue\QueueManager;
use Illuminate\Contracts\Http\Kernel;
use Swoole\Http\Server as HttpServer;
use Illuminate\Support\ServiceProvider;
use SwooleTW\Http\Middleware\AccessLog;
use SwooleTW\Http\Server\Facades\Server;
use Illuminate\Database\DatabaseManager;
use SwooleTW\Http\Coroutine\MySqlConnection;
Expand Down Expand Up @@ -62,11 +60,18 @@ public function register()
abstract protected function registerManager();

/**
* Boot routes.
* Boot websocket routes.
*
* @return void
*/
abstract protected function bootRoutes();
abstract protected function bootWebsocketRoutes();

/**
* Register access log middleware to container.
*
* @return void
*/
abstract protected function pushAccessLogMiddleware();

/**
* Boot the service provider.
Expand All @@ -88,7 +93,7 @@ public function boot()
}

if ($config->get('swoole_http.server.access_log')) {
$this->app->make(Kernel::class)->pushMiddleware(AccessLog::class);
$this->pushAccessLogMiddleware();
}
}

Expand Down
16 changes: 14 additions & 2 deletions src/LaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace SwooleTW\Http;

use SwooleTW\Http\Server\Manager;
use Illuminate\Contracts\Http\Kernel;
use SwooleTW\Http\Middleware\AccessLog;

/**
* @codeCoverageIgnore
Expand All @@ -24,12 +26,22 @@ protected function registerManager()
}

/**
* Boot routes.
* Boot websocket routes.
*
* @return void
*/
protected function bootRoutes()
protected function bootWebsocketRoutes()
{
require __DIR__ . '/../routes/laravel_routes.php';
}

/**
* Register access log middleware to container.
*
* @return void
*/
protected function pushAccessLogMiddleware()
{
$this->app->make(Kernel::class)->pushMiddleware(AccessLog::class);
}
}
16 changes: 14 additions & 2 deletions src/LumenServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SwooleTW\Http;

use SwooleTW\Http\Server\Manager;
use SwooleTW\Http\Middleware\AccessLog;

/**
* @codeCoverageIgnore
Expand All @@ -24,14 +25,15 @@ protected function registerManager()
}

/**
* Boot routes.
* Boot websocket routes.
*
* @return void
*/
protected function bootRoutes()
protected function bootWebsocketRoutes()
{
$app = $this->app;

// router only exists after lumen 5.5
if (property_exists($app, 'router')) {
$app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function ($app) {
require __DIR__ . '/../routes/lumen_routes.php';
Expand All @@ -42,4 +44,14 @@ protected function bootRoutes()
});
}
}

/**
* Register access log middleware to container.
*
* @return void
*/
protected function pushAccessLogMiddleware()
{
$this->app->middleware(AccessLog::class);
}
}

0 comments on commit ecbb01c

Please sign in to comment.