proxima

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 4 Imported by: 0

README

Proxima 7

One of the reasons this reverse proxy is made because I need to modify client request and response from the server. Feel free to contribute 😉

Usage

Using Proxima 7 is as simple as this:

package main

import (
    "github.com/dityaaa/proxima"
    "net/http"
)

func main() {
    proxy := proxima.New("http://example.com/")

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        proxy.HandleRequests(w, r)
    })
	
    http.ListenAndServe(":80", nil)
}

After that, you can start browse localhost. You will get respond like the target URL you have entered.

To modify request or response, you can use OnRequest and OnResponse

proxy.OnRequest(func(req *http.Request) {
    // do anything to request
})

proxy.OnResponse(func(res *http.Response) {
    // do anything to response
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New added in v0.2.0

func New(target string) (server *Server, err error)

Initialize new Proxima 7

func (*Server) HandleRequests

func (s *Server) HandleRequests(w http.ResponseWriter, r *http.Request)

func (*Server) OnRequest

func (s *Server) OnRequest(callback func(req *http.Request))

func (*Server) OnResponse

func (s *Server) OnResponse(callback func(res *http.Response))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL