Skip to content

Commit 0a2f10e

Browse files
committed
added rudimentary support for each of the seven HTTP methods (GET, PUT, POST, DELETE, OPTION, HEAD, and PATCH)
1 parent 823a18e commit 0a2f10e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Tic-Tac-Toe/src/app/highscore/highscore.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class HighscoreComponent {
1414
public highscores$ = new Subject<Highscore[]>();
1515

1616
constructor(public engineService: EngineService, http: Http) {
17-
http.get("https://example.com/rest/highscore.json").subscribe(response => {
17+
http.get("https://example.com/rest/highscore").subscribe(response => {
1818
this.highscores$.next(response.json() as Highscore[]);
1919
});
2020
}

Tic-Tac-Toe/src/app/mock-http/mock-http.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import {Inject, NgModule} from '@angular/core';
22
import {CommonModule} from '@angular/common';
33
import {MockBackend, MockConnection} from "@angular/http/testing";
44
import {
5-
BaseRequestOptions, Connection, Http, HttpModule, Response, ResponseOptions, ResponseType,
5+
BaseRequestOptions, Connection, Http, HttpModule, RequestMethod, Response, ResponseOptions, ResponseType,
66
XHRBackend
7-
} from "@angular/http";
7+
} from '@angular/http';
88
import 'rxjs/Rx';
99
import {Observable} from "rxjs";
1010

@@ -54,6 +54,8 @@ export class MockHttpModule {
5454
if (url.startsWith("https://example.com/rest/")) {
5555
url = "/assets/mock/" + url.substring("https://example.com/rest/".length);
5656
}
57+
let methodname= RequestMethod[connection.request.method];
58+
url += "/" + methodname + ".json";
5759
}
5860
const responseObservable: Observable<void> = realHttp.get(url).map(
5961
response => {

0 commit comments

Comments
 (0)