modules

package
v0.0.0-...-0c84e95 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2015 License: GPL-2.0 Imports: 4 Imported by: 0

README

Modules

Modules are how this proxy works. The proxy registers modules, and each module implemtents two functions:

  • filterRequest() - this filters outgoing requests from hitting the intended target and can have any effect. For example, dropping the request or sending a different one
  • filterResponse() - this filters incoming responses before they hit the app and can have any effect. For example, sending an empty response, or a carefully crafted different one.

Writing a module

To write a module, you create a struct in a new package and implement the Module interface (package main, modules.go). The module itself will be a struct with one field, MetaStuct which contains the metadata. For the sake of consistency, please call it Metadta (case sensitive). It also helps to create a constructor for the module (i.e. func NewMyModule() *MyModule).

Registering modules

To register the module for use within the proxy, call the RegisterModule function in main.go, function main (i.e. RegisterModule(mymodule.NewMyModule()).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClosingBuffer

type ClosingBuffer struct {
	io.Reader
}

struct to implement io.ReadCloser

func (ClosingBuffer) Close

func (cb ClosingBuffer) Close() (err error)

type MetaStruct

type MetaStruct struct {
	ModuleName    string
	VersionNumber string
	Service       string
}

func NewMetaStruct

func NewMetaStruct(name, ver, service string) *MetaStruct

func (MetaStruct) PrintMetaData

func (m MetaStruct) PrintMetaData()

type Module

type Module interface {
	Init()
	FilterRequest(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response)
	FilterResponse(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Response
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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