2017 © Pedro Peláez
 

library accept-header-service-provider

A service provider to help enable accept header filtering for routes

image

pff/accept-header-service-provider

A service provider to help enable accept header filtering for routes

  • Monday, October 8, 2012
  • by jmather
  • Repository
  • 1 Watchers
  • 9 Stars
  • 7,471 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

Accept Header Service Provider

Build Status, (*1)

This serivce provider enables you to easily filter routes based on accept headers in Silex., (*2)

To install, require the package through composer (or install it any other way you care to...), (*3)

"pff/accept-header-service-provider": "dev-master"

To use it, simply do the following:, (*4)

    <?php

    use Pff\ServiceProvider\AcceptHeaderServiceProvider\AcceptHeaderServiceProvider;

    $app->register(new AcceptHeaderServiceProvider());

    $app->get('/test', function($accept_header) {
        if ($accept_header == 'application/ven.test.v1+json')
            $cont = json_encode(array('content' => 'hello'));
        else
            $cont = '<content>hello</content>';

        return new Response($cont, 200, array('Content-Type' => $accept_header));
    })->accept(array('application/ven.test.v1+json', 'application/ven.test.v1+xml'));


    $app->get('/test', function($accept_header) {
        if ($accept_header == 'application/ven.test.v2+json')
            $cont = json_encode(array('content' => 'hiya'));
        else
            $cont = '<content>hiya</content>';

        return new Response($cont, 200, array('Content-Type' => $accept_header));
    })->accept(array('application/ven.test.v2+json', 'application/ven.test.v2+xml'));

Now a request with accept headers including application/ven.test.v1+json and application/ven.test.v1+xml will be handled by the first route, and requests with accept headers including application/ven.test.v2+json and application/ven.test.v2+xml will be routed to the second., (*5)

The Versions

08/10 2012

dev-master

9999999-dev

A service provider to help enable accept header filtering for routes

  Sources   Download

The Requires

 

The Development Requires

04/10 2012

v0.1.4

0.1.4.0

A service provider to help enable accept header filtering for routes

  Sources   Download

The Requires

 

The Development Requires

04/10 2012

v0.1.3

0.1.3.0

A service provider to help enable accept header filtering for routes

  Sources   Download

The Requires

 

The Development Requires

04/10 2012

v0.1.2

0.1.2.0

A service provider to help enable accept header filtering for routes

  Sources   Download

The Requires

 

The Development Requires

04/10 2012

v0.1.1

0.1.1.0

A service provider to help enable accept header filtering for routes

  Sources   Download

The Requires

 

The Development Requires

04/10 2012

v0.1.0

0.1.0.0

A service provider to help enable accept header filtering for routes

  Sources   Download

The Requires

 

The Development Requires