Git Product home page Git Product logo

aproxy's Introduction

APROXY

An Advanced Application Proxy

Introduction

AProxy (An Advanced Application Proxy) is a way to translate complex and generic REST requests into more simplified and specific requests.

Features:

  • scalable "hot plugging/unplugging" of advanced request proxy/re-write configurations (also called Mappings)
  • advanced url and body generation using GO Templates

Example

The following complex request

POST http://api.com/service/application/challenge_result/_search?search_type=count&pretty
{
"aggs": {
    "most_played_challenges": {
      "terms": {
        "field": "_parent",
        "order" : { "_count" : "desc" }
      }
    }
  }
}

Can be turned into a simple request

GET http://application.com/challenges/popular

By using the following configuration (or Mapping)

{
  "mappings" : {
    "indexer" : {
      "target" : {
        "headers" : {
          "Content-Type" : "application/json; charset=UTF-8"
        },
        "verb" : "POST",
        "uri" : "http://api.com/service/application/challenge_result/_search?search_type=count&pretty",
        "body" : "
        {
          \"aggs\"": {
            \"most_played_challenges\": {
              \"terms\": {
                \"field\" : \"_parent\",
                \"order\" : { \"_count\" : \"desc\" }
              }
            }
          }
        }
      "
      },
      "mapping" : {
        "request.path" : "(?i)^/challenges/popular/?$"
      }
    }
  }
}

Mappings

AProxy mappings take the form of

{
  "mappings" : {
    "<NAME>" : {
      "target" : {
        "headers" : {"<HEADER_NAME>" : "<HEADER_VALUE>"},
        "verb" : "GET|POST|PUT|DELETE|OPTION|HEAD",
        "uri" : "<URI_TEMPLATE>",
        "body" : "<BODY_TEMPLATE>"
      },
      "mapping" : {
        "<PROPERTY_NAME1>" : "<REGULAR_EXPRESSION>"
      }
    }
  }
}

Each mapping has a which is a unique identifier. Every mapping has a target property:

  • headers a list of headers to send to the underlying service
  • verb verb to use in request to the underlying service
  • uri uri to the underlying service, this is a template and not a simple string
  • body body to send to the underlying service, this is a template and not a simple string

Every mapping also has a mapping property, this is a map of property names and regular expressions used to map this particular mapping to incoming requests.

properties available for mappings and templates are:

  • request.method request verb, ex: GET, POST, PUT, OPTION, DELETE, HEAD
  • request.path ex: /twitter/123451
  • request.host ex: www.google.com
  • request.uri raw uri, ex: /twitter/123451?id=4512&ref=sau
  • request.content-length ex: 1024
  • query.xxx always lower-cased, ex: /twitter/123451?id=4512&ref=sau will avail query.id and query.ref
  • header.xxx always lower-cased, ex: header.content-type, header.user-agent

aproxy's People

Contributors

creamdog avatar

Watchers

 avatar James Cloos avatar

Forkers

frontierpsycho

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.