proxy

package
v2.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package access provides an access logging handler for the ozzo routing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPProxyHandler

func HTTPProxyHandler(proxys []*Proxy) routing.Handler

func ProxyHandler

func ProxyHandler(proxys []*Proxy) routing.Handler

ProxyHandler returns a handler that proxy config for every request. all request will pass through is match rule, if matched it will proxy request to upstream address.

import (
    "log"
    "github.com/ltick/tick-routing"
    "github.com/ltick/tick-routing/proxy"
    "net/http"
)

proxys = []*Proxy{
    &Proxy{Rule:"http://www.example.com/\w+.html/", Upstream:"http://127.0.0.1:9000/index.html"}
}
r := routing.New()
r.Use(access.Proxy(proxys))

Types

type Proxy

type Proxy struct {
	MethodRule     string
	HostRule       string
	UriRule        string
	UpstreamURL    *url.URL
	UpstreamHeader *http.Header
}

func (*Proxy) MatchProxy

func (p *Proxy) MatchProxy(r *http.Request) bool

Jump to

Keyboard shortcuts

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