@@ -248,56 +248,56 @@ export class Angular2TokenService implements CanActivate {
248248 }
249249
250250 // Standard HTTP requests
251- get ( path : string ) : Observable < Response > {
252- return this . request ( {
253- method : RequestMethod . Get ,
254- url : this . _constructApiPath ( ) + path
255- } ) ;
251+ get ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
252+ return this . request ( this . _mergeRequestOptionsArgs ( {
253+ url : this . _constructApiPath ( ) + url ,
254+ method : RequestMethod . Get
255+ } , options ) ) ;
256256 }
257257
258- post ( path : string , data : any ) : Observable < Response > {
259- return this . request ( {
258+ post ( url : string , body : any , options ?: RequestOptionsArgs ) : Observable < Response > {
259+ return this . request ( this . _mergeRequestOptionsArgs ( {
260+ url : this . _constructApiPath ( ) + url ,
260261 method : RequestMethod . Post ,
261- url : this . _constructApiPath ( ) + path ,
262- body : data
263- } ) ;
262+ body : body
263+ } , options ) ) ;
264264 }
265265
266- put ( path : string , data : any ) : Observable < Response > {
267- return this . request ( {
266+ put ( url : string , body : any , options ?: RequestOptionsArgs ) : Observable < Response > {
267+ return this . request ( this . _mergeRequestOptionsArgs ( {
268+ url : this . _constructApiPath ( ) + url ,
268269 method : RequestMethod . Put ,
269- url : this . _constructApiPath ( ) + path ,
270- body : data
271- } ) ;
270+ body : body
271+ } , options ) ) ;
272272 }
273273
274- delete ( path : string ) : Observable < Response > {
275- return this . request ( {
276- method : RequestMethod . Delete ,
277- url : this . _constructApiPath ( ) + path
278- } ) ;
274+ delete ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
275+ return this . request ( this . _mergeRequestOptionsArgs ( {
276+ url : this . _constructApiPath ( ) + url ,
277+ method : RequestMethod . Delete
278+ } , options ) ) ;
279279 }
280280
281- patch ( path : string , data : any ) : Observable < Response > {
282- return this . request ( {
281+ patch ( url : string , body : any , options ?: RequestOptionsArgs ) : Observable < Response > {
282+ return this . request ( this . _mergeRequestOptionsArgs ( {
283+ url : this . _constructApiPath ( ) + url ,
283284 method : RequestMethod . Patch ,
284- url : this . _constructApiPath ( ) + path ,
285- body : data
286- } ) ;
285+ body : body
286+ } , options ) ) ;
287287 }
288288
289- head ( path : string ) : Observable < Response > {
289+ head ( path : string , options ?: RequestOptionsArgs ) : Observable < Response > {
290290 return this . request ( {
291291 method : RequestMethod . Head ,
292292 url : this . _constructApiPath ( ) + path
293293 } ) ;
294294 }
295295
296- options ( path : string ) : Observable < Response > {
297- return this . request ( {
298- method : RequestMethod . Options ,
299- url : this . _constructApiPath ( ) + path
300- } ) ;
296+ options ( url : string , options ?: RequestOptionsArgs ) : Observable < Response > {
297+ return this . request ( this . _mergeRequestOptionsArgs ( {
298+ url : this . _constructApiPath ( ) + url ,
299+ method : RequestMethod . Options
300+ } , options ) ) ;
301301 }
302302
303303 // Construct and send Http request
@@ -331,6 +331,16 @@ export class Angular2TokenService implements CanActivate {
331331 return response ;
332332 }
333333
334+ private _mergeRequestOptionsArgs ( options : RequestOptionsArgs , addOptions ?: RequestOptionsArgs ) : RequestOptionsArgs {
335+
336+ let returnOptions : RequestOptionsArgs = options ;
337+
338+ if ( options )
339+ ( < any > Object ) . assign ( returnOptions , addOptions ) ;
340+
341+ return returnOptions ;
342+ }
343+
334344 // Check if response is complete and newer, then update storage
335345 private _handleResponse ( response : Observable < Response > ) {
336346 response . subscribe ( res => {
0 commit comments