2017 © Pedro Peláez
 

library rest-proxifier

proxy your rest api

image

arthurh/rest-proxifier

proxy your rest api

  • Monday, April 20, 2015
  • by ArthurHlt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

rest-proxifier

The goal of this project is to proxy your rest api., (*1)

Why do this?

First, it was initialized when I found that some rest api doesn't handle CORS., (*2)

This project will reinject CORS headers for angularjs project for example., (*3)

This project will also cache response for read request., (*4)

NOTE: Rest-proxifier use pathinfo so set your web server to use it., (*5)

NOTE2: This project is Cloud Foundry Ready, so you can also use it inside Cloud Foundry to handle uaa rest api for example., (*6)

Installation

Through Composer, obviously:, (*7)

$ composer create-project arthurh/rest-proxifier path/

How to use

You can use rest-proxifier in multiple ways: - Proxy from cnnfig file - Proxy from CloudFoundry Services if you use CloudFoundry - Proxy from database entries, (*8)

Theses 3 ways can be used in same time, there is no limit., (*9)

For simple use, look at config/default.yml:, (*10)

proxyfy:
  - api: http://example.com
    route: /api
    #this is optionnal
    #request-header:
    #  header-key: header-value
    #response-header:
    #  header-key: header-value
    #response-content: ~
admin-ui: true #set to false to remove admin interface
admin-ui-root: /admin #path to admin ui
rewriting: false #set to true if you use rewriting to point directly on index.php
caching-time: 20 minutes #set to false to remove caching
log-request: true #set to false to stop logs user request to proxify
database: false #or uri to database, e.g: mysql://root:password@localhost/mydb or special uri for sqlite: sqlite:/path, this is optionnal

This file can be rewrite in json or in xml too, it uses this dependency noodlehaus/config so follow schemas from this dependency if you don't want use yaml., (*11)

For this default config there is an example, a route is already set., (*12)

What you should do to try is to go to http://<my hostname>/index.php/api and rest-proxifier will respond the page http://example.com with CORS headers., (*13)

If you do http://<my hostname>/index.php/api/other/verb/for/api rest-proxifier will respond http://example.com/other/verb/for/api., (*14)

Admin interface

By default you have an interface located on http://<my hostname>/index.php/admin., (*15)

You can use it to add more proxy only on a database., (*16)

Proxies from config file can't be modify with this interface with the goal make accessible all the time theses proxies., (*17)

For Cloud Foundry user

This part is only for people who use the Cloud Foundry PaaS., (*18)

You can create a service which contain proxy (use regex to find service) in his name with this json value for example:, (*19)

[
    {
      "api": "http://example.com",
      "route": "/api"
    }
]

And rest-proxifier will auto-bind to this service, (*20)

You can also create a database service which should contains at least one of theses values in its name (use regex to find service): - my (for mysql) - db - database - oracle - oci - postgres - pgsql - maria, (*21)

And rest-proxifier will auto-bind database to this service, (*22)

The Versions