enniel/ami-hook

Asterisk AMI 的 Webhook API

dev-master / 1.0.x-dev 2017-02-03 09:58 UTC

This package is auto-updated.

Last update: 2024-09-06 04:14:10 UTC


README

Asterisk AMI 的 Webhook API。

安装

通过 Composer

$ composer require enniel/ami-hook

将服务提供商添加到您的 config/app.php

...
'providers' => [
    ...
    Enniel\AmiHook\AmiHookServiceProvider::class,
],
...

发布并运行迁移以创建将保存所有已安装 Webhook 的 webhooks 表。

php artisan vendor:publish --provider="Mpociot\CaptainHook\CaptainHookServiceProvider"

php artisan migrate

有关 Webhook 的更多信息,请参阅 mpociot/captainhook

接下来,您应该在 RouteServiceProvider 的启动方法中调用 AmiHook::routes 方法。此方法将注册 Webhook 路由

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Enniel\AmiHook\AmiHook;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        //

        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapApiRoutes();

        $this->mapWebRoutes();

        //
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/web.php');
        });
    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        AmiHook::routes(null, [
            'middleware' => 'auth:api',
            'prefix' => 'api',
        ]);

        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => 'api',
        ], function ($router) {
            require base_path('routes/api.php');
        });
    }
}

贡献

请参阅 CONTRIBUTINGCONDUCT 以获取详细信息。

安全

如果您发现任何与安全相关的问题,请通过电子邮件 razumov.evgeni@gmail.com 联系,而不是使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。请参阅 许可文件 以获取更多信息。