jonahkh
2020-05-15 12d85f8a71b4a43651d8f6c89b55ac40df15986e
commit | author | age
4829e4 1 # AB Proxy
J 2
3 The AB Proxy is a small application written in [Python](https://www.python.org/) + [Flask](https://flask.palletsprojects.com) 
4 which acts as a proxy for an endpoint and appends custom headers to all requests. 
5
6 ## How it works
7
8 The application exposes several endpoints to manage the behaviour of the proxy:
9  
10  - `GET /headers`: returns the list of headers the proxy is going to add to all requests.
11  - `DELETE /headers`: removes any configuration.
12  - `POST /headers`: sets the list of headers the proxy is going to add to all requests.
13
14 Setting headers example:
15 ```  
16 curl -d '{"version":"beta"}' -H "Content-Type: application/json" -X POST http://localhost:5000/headers
17 ```
18 ## Installation
19
20 The AB proxy is a Python application with Flask so, in order to run in your local machine you need Python + some 
21 libraries.
22
23 A simple approach is to have different Python virtual environments per project. Execute the following command in the
24 root of this project ot install a virtual environment:
25  
26 ```
27 $ python3 -m virtualenv venv
28 ```
29
30 Once the virtual environment is installed in the project, you need to activate this new virtual environment. Execute the 
31 following command to activate it:
32
33 ```
34 . venv/bin/activate
35 ```
36
37 After the activation of the virtual environment you need to install all the requirements for the service (unless you did
38 this step before). Execute the following command to install all the required libraries:
39
40 ```
41 pip install -r requirements.txt
42 ```
43
44 ## Running the AB proxy in local
45
46 To run the AB proxy in local, execute the following commands:
47
48 ```
49 $ cd src  
50 $ export FLASK_APP=ab-proxy.py  
51 $ flask run 
52 ```
53  
54  ## Running the AB proxy in a containers environment
55  
56 In order to run the AB proxy in a containers environment you need a container image. A prebuilt image is
57 available in [quay.io](https://quay.io/repository/redhattraining/ossm-ab-proxy)
58