Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NewProxyReverse = func(c ProxyReverse) *ProxyReverse { var host string = c.Host if c.Host == "" { host = "localhost" } if c.Port != "" { host = fmt.Sprintf("%s:%s", c.Host, c.Port) } if c.Protocol == "" { c.Protocol = "http" } targetHost := fmt.Sprintf("%s://%s", c.Protocol, host) p := &ProxyReverse{ Host: c.Host, Port: c.Port, Protocol: c.Protocol, } target, e := url.Parse(targetHost) if e != nil { p.error_ = errors.Errorf("Error parsing target host: %s Error: %s", targetHost, e.Error()) return p } p.reverseProxy = httputil.NewSingleHostReverseProxy(target) return p }
Create a new ProxyReverse parameter is a struct of type ProxyReverse with configured values for host, port and protocol
Functions ¶
This section is empty.
Types ¶
type ProxyReverse ¶
type ProxyReverse struct { Host string `json:"host"` // Host of petition if not specified will be localhost Port string `json:"port"` Protocol string `json:"protocol"` // Protocol of petition if not specified will be http // contains filtered or unexported fields }
func (*ProxyReverse) RequestProxy ¶
func (p *ProxyReverse) RequestProxy() gin.HandlerFunc
RequestProxy is a function that returns a gin.HandlerFunc. Process the request of the router and pass it to the ReverseProxy of type httputil.ReverseProxy, which processes the request and returns the response to router
Click to show internal directories.
Click to hide internal directories.