Yves is a simple HTTP(s) Man-in-The-Middle proxy.
- HTTP(s) Man-in-The-Middle proxy;
- Custom HTTP requests handlers;
- Custom HTTP responses handlers.
More usage examples can be found in the examples folder.
The following snippets of code shows how to start a simple mitm proxy. More usage examples can be found in the examples folder.
package main
import (
"log"
"net/http"
"github.com/rhaidiz/yves"
)
func main() {
// create a new mitm proxy
proxy := yves.NewProxy()
// Listen on local port 8080
log.Fatal(http.ListenAndServe(":8080", proxy))
}
The following example shows how to use request handler to add a custom header to every request:
proxy.HandleRequest = func(id int64, req *http.Request) *http.Response {
req.Header.Add("custom", "myval")
log.Printf("session: %v\n", id)
return nil
}
The following example shows how to prevent access to a requests performed toward a specific host.
proxy.HandleRequest = func(id int64, req *http.Request) *http.Response {
if req.Host == "example.com" {
return &http.Response{StatusCode: 500}
}
return nil