// redirectHandler returns a config options that decorates the default response handling routine;
// it transforms normal Mesos redirect "errors" into mesosRedirectionErrors by parsing the Location
// header and computing the address of the next endpoint that should be used to replay the failed
// HTTP request.
redirectHandler returns a config options that decorates the default response handling routine;
it transforms normal Mesos redirect "errors" into mesosRedirectionErrors by parsing the Location
header and computing the address of the next endpoint that should be used to replay the failed
HTTP request.
// redirectHandler returns a config options that decorates the default response handling routine ; // it transforms normal Mesos redirect " errors " into mesosRedirectionErrors by parsing the Location // header and computing the address of the next endpoint that should be used to replay the failed // HTTP request .
func (cli *client) redirectHandler() httpcli.Opt {
	return httpcli.HandleResponse(func(hres *http.Response, err error) (mesos.Response, error) {
		resp, err := cli.HandleResponse(hres, err) 
		if err == nil || (err != nil && err != httpcli.ErrNotLeader) {
			return resp, err
		}
		res, ok := resp.(*httpcli.Response)
		if !ok {
			if resp != nil {
				resp.Close()
			}
			return nil, errNotHTTP
		}
		log.Println("master changed?")
		location, ok := buildNewEndpoint(res.Header.Get("Location"), cli.Endpoint())
		if !ok {
			return nil, errBadLocation
		}
		res.Close()
		return nil, &mesosRedirectionError{location}
	})
}
func ( cli * client ) redirectHandler ( ) httpcli . Opt { return httpcli . HandleResponse ( func ( hres * http . Response , err error ) ( mesos . Response , error ) { resp , err := cli . HandleResponse ( hres , err ) if err == nil || ( err != nil && err != httpcli . ErrNotLeader ) { return resp , err } res , ok := resp . ( * httpcli . Response ) if ! ok { if resp != nil { resp . Close ( ) } return nil , errNotHTTP } log . Println ( " " ) location , ok := buildNewEndpoint ( res . Header . Get ( " " ) , cli . Endpoint ( ) ) if ! ok { return nil , errBadLocation } res . Close ( ) return nil , & mesosRedirectionError { location } } ) }
redirectHandler returns a config options that decorates the default response handling routine;
it transforms normal Mesos redirect "errors" into mesosRedirectionErrors by parsing the Location
header and computing the address of the next endpoint that should be used to replay the failed
HTTP request.
redirectHandler returns a config options that decorates the default response handling routine ; it transforms normal Mesos redirect " errors " into mesosRedirectionErrors by parsing the Location header and computing the address of the next endpoint that should be used to replay the failed HTTP request .
// default response handler