func (p *AuthProxy) Listen() error {
	mux := bone.New()
	proxy := &httputil.ReverseProxy{
		Transport: p.t,
		Director: func(r *http.Request) {
			r.URL.Scheme = p.u.Scheme
			r.URL.Host = p.u.Host
			r.Host = p.u.Host
			r.URL.Path = r.URL.Path[6:]

			tok := p.sess.Token()
			if tok != "" {
				r.Header["Authorization"] = []string{"Bearer " + tok}
			}

			r.Header["User-Agent"] = []string{"Torus-Daemon/" + p.c.Version}
			r.Header["X-Registry-Version"] = []string{p.c.APIVersion}
		},
	}

	go p.o.Start()

	mux.HandleFunc("/proxy/", proxyCanceler(proxy))
	mux.SubRoute("/v1", routes.NewRouteMux(p.c, p.sess, p.db, p.t, p.o, p.client, p.logic))

	h := httpdown.HTTP{}
	p.s = h.Serve(&http.Server{Handler: requestIDHandler(loggingHandler(mux))}, p.l)

	return p.s.Wait()
}
// Listen starts the main loop of the AuthProxy. It returns on error, or when
// the AuthProxy is closed.
Listen starts the main loop of the AuthProxy. It returns on error, or when
the AuthProxy is closed.
// Listen starts the main loop of the AuthProxy . It returns on error or when // the AuthProxy is closed .
func (p *AuthProxy) Listen() error {
	mux := bone.New()
	proxy := &httputil.ReverseProxy{
		Transport: p.t,
		Director: func(r *http.Request) {
			r.URL.Scheme = p.u.Scheme
			r.URL.Host = p.u.Host
			r.Host = p.u.Host
			r.URL.Path = r.URL.Path[6:]
			tok := p.sess.Token()
			if tok != "" {
				r.Header["Authorization"] = []string{"Bearer " + tok}
			}
			r.Header["User-Agent"] = []string{"Torus-Daemon/" + p.c.Version}
			r.Header["X-Registry-Version"] = []string{p.c.APIVersion}
		},
	}
	go p.o.Start()
	mux.HandleFunc("/proxy/", proxyCanceler(proxy))
	mux.SubRoute("/v1", routes.NewRouteMux(p.c, p.sess, p.db, p.t, p.o, p.client, p.logic))
	h := httpdown.HTTP{}
	p.s = h.Serve(&http.Server{Handler: requestIDHandler(loggingHandler(mux))}, p.l)
	return p.s.Wait()
}
func ( p * AuthProxy ) Listen ( ) error { mux := bone . New ( ) proxy := & httputil . ReverseProxy { Transport : p . t , Director : func ( r * http . Request ) { r . URL . Scheme = p . u . Scheme r . URL . Host = p . u . Host r . Host = p . u . Host r . URL . Path = r . URL . Path [ 6 : ] tok := p . sess . Token ( ) if tok != " " { r . Header [ " " ] = [ ] string { " " + tok } } r . Header [ " " ] = [ ] string { " " + p . c . Version } r . Header [ " " ] = [ ] string { p . c . APIVersion } } , } go p . o . Start ( ) mux . HandleFunc ( " " , proxyCanceler ( proxy ) ) mux . SubRoute ( " " , routes . NewRouteMux ( p . c , p . sess , p . db , p . t , p . o , p . client , p . logic ) ) h := httpdown . HTTP { } p . s = h . Serve ( & http . Server { Handler : requestIDHandler ( loggingHandler ( mux ) ) } , p . l ) return p . s . Wait ( ) }
Listen starts the main loop of the AuthProxy.
Listen starts the main loop of the AuthProxy .