zmarquez/stackphp-ampcors

AMP CORS middleware for StackPHP

v1.1 2020-01-13 17:03 UTC

This package is auto-updated.

Last update: 2024-04-14 23:09:31 UTC


README

This package contains a StackPHP middleware that manages the AMP security CORS requests.

Options

The AmpCorsMiddleware accepts an array of options:

  • publisherOrigin: contains the value of the source origin.
  • queryString: array with parameters to add of the request.

Example

<?php

use Zmc\Stack\AmpCorsMiddleware;

require_once __DIR__ . '../vendor/autoload.php';

$app = new Silex\Application();

$stack = (new Stack\Builder())
    ->push(
        AmpCorsMiddleware::class,
        [
            'publisherOrigin' => 'https://example.com',
            'queryString' => [
                'lang' => 'es'
            ]
        ]);

$app = $stack->resolve($app);

$request = Request::createFromGlobals();
$response = $app->handle($request)->send();

$app->terminate($request, $response);

Installation

The recommended way to install AmpCorsMiddleware is through Composer:

{
    "require": {
        "zmarquez/stackphp-ampcors": "dev-master"
    }
}