Simple Proxy
Simple Proxy is a lightweight and easy-to-use proxy server built with Ruby, Sinatra, and HTTParty. It's designed to forward requests to specified target URLs, making it a versatile tool for developers working with APIs and web services.
Features
- Supports GET, POST, and PUT HTTP methods.
- Supports Cross-Origin Resource Sharing (CORS) with
Sinatra::CrossOrigin
. - Transfers headers and parameters to the target URL.
- Provides mechanisms for starting and stopping the server.
Installation
To install Simple Proxy, you can add this line to your application's Gemfile:
gem 'simple_proxy'
and then execute:
bundle install
or simply install it from the command line:
gem install simple_proxy
Usage
To use Simple Proxy, you can require it in your application:
require 'simple_proxy'
Starting the Server
To start the server:
SimpleProxy.run!
Stopping the Server
To stop the server:
SimpleProxy.quit!
CLI
You can also start or stop the server from the command line:
simple_proxy start
simple_proxy stop
Proxying Requests
To proxy requests, you can use the '/proxy' endpoint:
get '/proxy' do
SimpleProxy.proxy(params, request)
end
Making Proxy Requests
Once the server is running, you can make proxy requests to the following endpoints:
- GET /proxy?url=target_url
- POST /proxy?url=target_url
- PUT /proxy?url=target_url
- HEAD /proxy?url=target_url
- DELETE /proxy?url=target_url
Replace target_url with the URL you want to proxy the request to.
Contributing
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
- Fork it (https://github.com/Hetu-Labs/simple_proxy/fork)
- Create your feature branch (git checkout -b feature/fooBar)
- Commit your changes (git commit -am 'Add some fooBar')
- Push to the branch (git push origin feature/fooBar)
- Create a new Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.
Changelog
For all notable changes made to this project, see the Changelog.