81
81
"--protocol-rewrite <proto>" ,
82
82
"Rewrite the Location header protocol in redirect responses to the specified protocol"
83
83
)
84
+ . option (
85
+ "--custom-header <header>" ,
86
+ "Custom header to add to proxied requests. Use same option for multiple headers (--custom-header k1:v1 --custom-header k2:v2)" ,
87
+ collect , [ ]
88
+ )
84
89
. option ( "--insecure" , "Disable SSL cert verification" )
85
90
. option ( "--host-routing" , "Use host routing (host as first level of path)" )
86
91
. option ( "--statsd-host <host>" , "Host to send statsd statistics to" )
@@ -102,6 +107,10 @@ args
102
107
"Define an external storage class. Defaults to in-MemoryStore."
103
108
) ;
104
109
110
+ function collect ( value , previous ) {
111
+ return previous . concat ( [ value ] ) ;
112
+ }
113
+
105
114
args . parse ( process . argv ) ;
106
115
107
116
var ConfigurableProxy = require ( "../lib/configproxy.js" ) . ConfigurableProxy ;
@@ -300,6 +309,24 @@ if (!options.authToken) {
300
309
log . warn ( "REST API is not authenticated." ) ;
301
310
}
302
311
312
+ // custom headers option
313
+ options . customHeader = [ ] ;
314
+ if ( args . customHeader ) {
315
+ options . customHeader = args . customHeader . map ( s => s . trim ( ) ) . map ( header => {
316
+ var i = header . indexOf ( ':' ) ;
317
+ var key , value ;
318
+ if ( i < 0 ) {
319
+ log . error ( "Custom header is invalid: " + header ) ;
320
+ process . exit ( 1 ) ;
321
+ }
322
+ else {
323
+ var key = header . substr ( 0 , i ) . trim ( ) ;
324
+ var value = header . substr ( i + 1 ) . trim ( ) ;
325
+ }
326
+ return { 'key' : key , 'value' : value } ;
327
+ } ) . filter ( header => header . key ) ;
328
+ }
329
+
303
330
// external backend class
304
331
options . storageBackend = args . storageBackend ;
305
332
0 commit comments