src/app/core/auth/auth-http.service.ts
Methods |
|
constructor(authService: AuthService, http: Http)
|
||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:8
|
||||||||||||
Parameters :
|
Public delete | ||||||||||||
delete(url: string, options?: RequestOptionsArgs)
|
||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:25
|
||||||||||||
Parameters :
Returns :
Observable<Response>
|
Public download | ||||||||
download(url: string)
|
||||||||
Defined in src/app/core/auth/auth-http.service.ts:41
|
||||||||
Parameters :
Returns :
any
|
Public downloadPost |
downloadPost(url: string, body: any)
|
Defined in src/app/core/auth/auth-http.service.ts:45
|
Returns :
any
|
Public get | ||||||||||||
get(url: string, options?: RequestOptionsArgs)
|
||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:13
|
||||||||||||
Parameters :
Returns :
Observable<Response>
|
Public head | ||||||||||||
head(url: string, options?: RequestOptionsArgs)
|
||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:33
|
||||||||||||
Parameters :
Returns :
Observable<Response>
|
Public options | ||||||||||||
options(url: string, options?: RequestOptionsArgs)
|
||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:37
|
||||||||||||
Parameters :
Returns :
Observable<Response>
|
Public patch | ||||||||||||||||
patch(url: string, body: any, options?: RequestOptionsArgs)
|
||||||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:29
|
||||||||||||||||
Parameters :
Returns :
Observable<Response>
|
Public post | ||||||||||||||||
post(url: string, body: any, options?: RequestOptionsArgs)
|
||||||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:17
|
||||||||||||||||
Parameters :
Returns :
Observable<Response>
|
Private processError | ||||||||
processError(response: Response)
|
||||||||
Defined in src/app/core/auth/auth-http.service.ts:49
|
||||||||
Parameters :
Returns :
any
|
Public put | ||||||||||||||||
put(url: string, body: any, options?: RequestOptionsArgs)
|
||||||||||||||||
Defined in src/app/core/auth/auth-http.service.ts:21
|
||||||||||||||||
Parameters :
Returns :
Observable<Response>
|
import {Injectable} from "@angular/core";
import {AuthService} from "./auth.service";
import {Http, RequestOptionsArgs, Response, ResponseContentType} from "@angular/http";
import {Observable} from "rxjs";
import 'rxjs/add/operator/map';
@Injectable()
export class AuthHttp {
constructor(private authService: AuthService, private http: Http) {
}
public get(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.http.get(url, options).catch(error => this.processError(error));
}
public post(url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
return this.http.post(url, body, options).catch(error => this.processError(error));
}
public put(url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
return this.http.put(url, body, options).catch(error => this.processError(error));
}
public delete(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.http.delete(url, options).catch(error => this.processError(error));
}
public patch(url: string, body: any, options?: RequestOptionsArgs): Observable<Response> {
return this.http.patch(url, body, options).catch(error => this.processError(error));
}
public head(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.head(url, options).catch(error => this.processError(error));
}
public options(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.options(url, options).catch(error => this.processError(error));
}
public download(url: string) {
return this.get(url, {responseType: ResponseContentType.Blob})
}
public downloadPost(url: string, body: any) {
return this.post(url, body, {responseType: ResponseContentType.Blob})
}
private processError(response: Response) {
this.authService.processUnauthorized(response);
return Observable.throw(response);
}
}