定制 middlewares/cors 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

middlewares/cors

最新稳定版本:v2.1.0

Composer 安装命令:

composer require middlewares/cors

包简介

Middleware to implement Cross-Origin Resource Sharing (CORS)

README 文档

README

Latest Version on Packagist Software License Testing Total Downloads

Middleware to implement Cross-Origin Resource Sharing (CORS) using neomerx/cors-psr7.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/cors.

composer require middlewares/cors

Example

use Neomerx\Cors\Strategies\Settings;
use Neomerx\Cors\Analyzer;

$settings = new Settings();
$settings->setServerOrigin('http', 'example.com', 123);

$analyzer = Analyzer::instance($settings);

$dispatcher = new Dispatcher([
    new Middlewares\Cors($analyzer)
]);

$response = $dispatcher->dispatch(new ServerRequest());

Usage

You have to provide a Neomerx\Cors\Contracts\AnalyzerInterface to the constructor. See neomerx/cors-psr7 for more info. Optionally, you can provide a Psr\Http\Message\ResponseFactoryInterface as the second argument to create the responses. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.

$analyzer = Analyzer::instance($settings);
$responseFactory = new MyOwnResponseFactory();

$cors = new Middlewares\Cors($analyzer, $responseFactory);

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 70.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-09