@@ -185,6 +185,41 @@ func (i *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
185185 Id : projectID ,
186186 Version : version ,
187187 }
188+ upstreamProxyHeaders := make ([]* gateway.ProxyHeader , 0 )
189+ var upstreamRelease * gateway.UpstreamRelease
190+ if len (upstreamCommitIds ) > 0 {
191+ upstreamCommits , err := i .upstreamService .ListCommit (ctx , upstreamCommitIds ... )
192+ if err != nil {
193+ return nil , err
194+ }
195+ for _ , c := range upstreamCommits {
196+ upstreamRelease = & gateway.UpstreamRelease {
197+ BasicItem : & gateway.BasicItem {
198+ ID : c .Target ,
199+ Version : version ,
200+ MatchLabels : map [string ]string {
201+ "serviceId" : projectID ,
202+ },
203+ },
204+ PassHost : c .Data .PassHost ,
205+ Scheme : c .Data .Scheme ,
206+ Balance : c .Data .Balance ,
207+ Timeout : c .Data .Timeout ,
208+ Nodes : utils .SliceToSlice (c .Data .Nodes , func (n * upstream.NodeConfig ) string {
209+ return fmt .Sprintf ("%s weight=%d" , n .Address , n .Weight )
210+ }),
211+ }
212+
213+ upstreamProxyHeaders = utils .SliceToSlice (c .Data .ProxyHeaders , func (n * upstream.ProxyHeader ) * gateway.ProxyHeader {
214+ return & gateway.ProxyHeader {
215+ Key : n .Key ,
216+ Value : n .Value ,
217+ Opt : n .OptType ,
218+ }
219+ })
220+ }
221+ r .Upstream = upstreamRelease
222+ }
188223 apis := make ([]* gateway.ApiRelease , 0 , len (apiInfos ))
189224 hasUpstream := len (upstreamCommitIds ) > 0
190225 for _ , a := range apiInfos {
@@ -221,38 +256,15 @@ func (i *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
221256 Opt : h .OptType ,
222257 }
223258 })
259+ apiInfo .ProxyHeaders = append (apiInfo .ProxyHeaders , upstreamProxyHeaders ... )
260+
224261 apiInfo .Retry = proxy .Retry
225262 apiInfo .Timeout = proxy .Timeout
226263 }
227264 apis = append (apis , apiInfo )
228265 }
229266 r .Apis = apis
230- var upstreamRelease * gateway.UpstreamRelease
231- if len (upstreamCommitIds ) > 0 {
232- upstreamCommits , err := i .upstreamService .ListCommit (ctx , upstreamCommitIds ... )
233- if err != nil {
234- return nil , err
235- }
236- for _ , c := range upstreamCommits {
237- upstreamRelease = & gateway.UpstreamRelease {
238- BasicItem : & gateway.BasicItem {
239- ID : c .Target ,
240- Version : version ,
241- MatchLabels : map [string ]string {
242- "serviceId" : projectID ,
243- },
244- },
245- PassHost : c .Data .PassHost ,
246- Scheme : c .Data .Scheme ,
247- Balance : c .Data .Balance ,
248- Timeout : c .Data .Timeout ,
249- Nodes : utils .SliceToSlice (c .Data .Nodes , func (n * upstream.NodeConfig ) string {
250- return fmt .Sprintf ("%s weight=%d" , n .Address , n .Weight )
251- }),
252- }
253- }
254- r .Upstream = upstreamRelease
255- }
267+
256268 if len (strategyCommitIds ) > 0 {
257269 strategyCommits , err := i .strategyService .ListStrategyCommit (ctx , strategyCommitIds ... )
258270 if err != nil {
0 commit comments