type ReverseProxy struct { // Director must be a function which modifies // the request into a new request to be sent // using Transport. Its response is then copied // back to the original client unmodified. // Director must not access the provided Request // after returning. //Director是一个函数,它接收一个请求作为参数, //修改请求后发送给后端服务器 //最后将接收到的请求原封不动的发送回客户端。 Director func(*http.Request) // Thetransportusedtoperformproxyrequests. // Ifnil, http.DefaultTransportisused. //用于执行代理请求 Transporthttp.RoundTripper // FlushIntervalspecifiestheflushinterval // toflushtotheclientwhilecopyingthe // responsebody. // Ifzero, noperiodicflushingisdone. // Anegativevaluemeanstoflushimmediately // aftereachwritetotheclient. // TheFlushIntervalisignoredwhenReverseProxy // recognizesaresponseasastreamingresponse; // forsuchresponses, writesareflushedtotheclient // immediately. FlushIntervaltime.Duration // ErrorLogspecifiesanoptionalloggerforerrors // thatoccurwhenattemptingtoproxytherequest. // Ifnil, logginggoestoos.Stderrviathelogpackage's // standardlogger. ErrorLog *log.Logger // Go 1.4 // BufferPooloptionallyspecifiesabufferpoolto // getbyteslicesforusebyio.CopyBufferwhen // copyingHTTPresponsebodies. BufferPoolBufferPool // Go 1.6 // ModifyResponseisanoptionalfunctionthatmodifiesthe // Responsefromthebackend. Itiscalledifthebackend // returnsaresponseatall, withanyHTTPstatuscode. // Ifthebackendisunreachable, theoptionalErrorHandleris // calledwithoutanycalltoModifyResponse. // // IfModifyResponsereturnsanerror, ErrorHandleriscalled // withitserrorvalue. IfErrorHandlerisnil, itsdefault // implementationisused. ModifyResponsefunc(*http.Response)error // Go 1.8 // ErrorHandlerisanoptionalfunctionthathandleserrors // reachingthebackendorerrorsfromModifyResponse. // // Ifnil, thedefaultistologtheprovidederrorandreturn // a 502 StatusBadGatewayresponse. ErrorHandlerfunc(http.ResponseWriter, *http.Request, error) // Go 1.11 }