gregleveque/gateway-bundle

Installs: 123

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.3 2020-08-06 21:03 UTC

This package is auto-updated.

Last update: 2024-09-27 17:04:10 UTC


README

Gie Gateaway Bundle

Table of Contents

Installation

composer require gregleveque/gateway-bundle

in AppKernel.php add

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Gie\GatwayBundle\GieGatewayBundle(),
        // ...
    ];
}

Configuration

gie_gateway:
  redis_dsn: 127.0.0.1 # default value
  routes:
    name:
      target: https://www.target.com
      query:
        a:
          - first
          - second
        b: 3
      headers:
        Content-Type: application/json
      ttl: 60 # default value

When using routes defined in configuration, the client parameters ALWAYS overrides configuration parameters. For querystring, if the variable is an array, the client replace the first value by default.

  • If you need to replace a configured value fron an array, use the index of the value in the querystring
...&a[1]=replaced
  • If you need to add a new value in the array, use an unused index
...&a=[3]=added

Client usage

  • Base route:
/api/gateway
  • Configured routes:
/api/gateway/{route-name}

When using the default route or configured routes, there is 2 custom headers:

  • X_GATEWAY_FORWARD: List of headers to forward separated by comma.
  • X_GATEWAY_TTL: Change the default TTL of the response (default 60s)