Exemple #1
0
// Run starts the proxy server specified by the config and interposing the provided middleware
func Run(config Config, mw ...middleware.MiddleWare) error {
	chain := alice.New()
	for _, m := range mw {
		chain = chain.Append(alice.Constructor(m))
	}

	proxy := httputil.NewSingleHostReverseProxy(&url.URL{Scheme: config.Scheme, Host: config.Host, Path: config.BasePath})
	return http.ListenAndServe(config.Addr, chain.Then(proxy))
}
Exemple #2
0
// Add adds a new middleware to the stack
func (s *Stack) Add(m ...Middleware) {
	for _, mdw := range m {
		s.Stack = s.Stack.Append(alice.Constructor(mdw))
	}
}