Giter Site home page Giter Site logo

goalkeeper's Introduction

Goal Keeper

GoalKeeper is a proxy. Just like any proxy it forwards requests and responses between client and server. However GoalKeeper allows you to setup 'rules' which will be inspected and execute once a request or response matches.

GoalKeeper comes with a Back End API and Backbone.js/jQuery/Bootstrap based administration webpage to easily setup rules and view logs.

Overview

                               Goal Keeper
                      +----------------------------+                     
                      |                            |                     
       Request --> o--|-------RegEx? -No-->Proxy-->|----> Request
                      |          |                 |
                      |         Yes                |
                      |          |                 |
Direct Response <-----|<-Direct-*JSCode->Modified->|----> Request (modified)
                      |  Resp.          Request    |
                      |                            |                         
                      |                            |
       Response <-----|<--Fwd resp<----No-RegEx?---|<---- Response  
                      |                      |     |
Modified Response <---|<-Mod Resp<--JSCode<-Yes    |
                      |                            |
                      +----------------------------+

Rules

Each request and response can be inspected with 'rules' that can be configured using the GK admin page.

For each rule:

  • Regular Expression used to inspect the body (sorry doesn't work on GET requests, yet)

  • Once a RegEx has a hit you can use JavaScript to manipulate the request and responses

The following properties can be present:

Request

  • method -> The method of the request (e.g. GET, POST, PUT, etc)

  • url -> The URL of the request (e.g. /a/b)

  • body -> The body of the request

Response

  • statusCode -> This will be the server response status code (e.g. 200 or 404)

  • body -> The body of the response

In case of a request, if you fill in the response details GoalKeeper will not proxy the request but immediately respond to the client.

You will need to set response.statusCode and optionally a body. If you leave response undefined on the request, GoalKeeper will proxy the request to the server.

Please call done(); at the end of your program to finish your changes and handle/proxy the request/response.

For example:

var response = {
    statusCode : 503,
    body : 'Hello World!'
};

done();

Will immediately return a 503 on the response with the Body: Hello World!

Prerequisites

GoalKeeper uses REDIS for key/value storage, it requires a redis server to connect to.

Installation

  1. npm install to install the required npm packages
  2. make sure Redis is running
  3. Configure your settings in config.js
  4. node goalKeeper
  5. Open browser to http://<ip of goalkeeper>:8081 for the administration webpage

Todo

  • Lots of testing, this project is in initial development stages

  • Handle errors, there are 2 sub processes of Goal Keeper. If one crashes, we should handle it gracefully (we just ignore it now)

  • Tons of UI options can be added: statistics, editing of rules/programs, better code editor

goalkeeper's People

Contributors

wouterlucas avatar

Watchers

 avatar  avatar  avatar

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.