Commit 3e0fcb24 authored by i317280's avatar i317280

bug fix

parent 7403a128
......@@ -2,12 +2,12 @@
* Created by liuzheng on 2017/8/31.
*/
import {Component} from '@angular/core';
import {AppService} from './app.service';
import {AppService, HttpService} from './app.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
providers: [AppService],
providers: [AppService, HttpService],
// directives: [LeftbarComponent, TermComponent]
})
......
......@@ -103,48 +103,73 @@ export let Browser: {
vendor: navigator.vendor,
};
@Injectable()
export class HttpService {
headers = new Headers();
constructor(private _http: Http) {
}
request(url: string | Request, options?: RequestOptionsArgs) {
options.headers = this.headers;
return this._http.request(url, options)
}
// request(url: string | Request, options?: RequestOptionsArgs) {
// if (options == null) {
// options = {};
// }
// options.headers = this.headers;
// return this._http.request(url, options)
// }
get(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.get(url, options)
}
post(url: string, body: any, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.post(url, body, options)
}
put(url: string, body: any, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.put(url, body, options)
}
delete(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.delete(url, options)
}
patch(url: string, body: any, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.patch(url, body, options)
}
head(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.head(url, options)
}
options(url: string, options?: RequestOptionsArgs) {
if (options == null) {
options = {};
}
options.headers = this.headers;
return this._http.options(url, options)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment