diff --git a/src/@fuse/lib/mock-api/mock-api.service.ts b/src/@fuse/lib/mock-api/mock-api.service.ts index 4d7eea28..30a06524 100644 --- a/src/@fuse/lib/mock-api/mock-api.service.ts +++ b/src/@fuse/lib/mock-api/mock-api.service.ts @@ -9,11 +9,14 @@ import { FuseMockApiMethods } from '@fuse/lib/mock-api/mock-api.types'; export class FuseMockApiService { private _handlers: { [key: string]: Map } = { - 'delete': new Map(), - 'get' : new Map(), - 'patch' : new Map(), - 'post' : new Map(), - 'put' : new Map() + 'get' : new Map(), + 'post' : new Map(), + 'patch' : new Map(), + 'delete' : new Map(), + 'put' : new Map(), + 'head' : new Map(), + 'jsonp' : new Map(), + 'options': new Map() }; /** @@ -86,18 +89,7 @@ export class FuseMockApiService } /** - * Register a DELETE request handler - * - * @param url - URL address of the mocked API endpoint - * @param delay - Delay of the response in milliseconds - */ - onDelete(url: string, delay?: number): FuseMockApiHandler - { - return this._registerHandler('delete', url, delay); - } - - /** - * Register a GET request handler + * Register GET request handler * * @param url - URL address of the mocked API endpoint * @param delay - Delay of the response in milliseconds @@ -108,18 +100,7 @@ export class FuseMockApiService } /** - * Register a PATCH request handler - * - * @param url - URL address of the mocked API endpoint - * @param delay - Delay of the response in milliseconds - */ - onPatch(url: string, delay?: number): FuseMockApiHandler - { - return this._registerHandler('patch', url, delay); - } - - /** - * Register a POST request handler + * Register POST request handler * * @param url - URL address of the mocked API endpoint * @param delay - Delay of the response in milliseconds @@ -130,7 +111,29 @@ export class FuseMockApiService } /** - * Register a PUT request handler + * Register PATCH request handler + * + * @param url - URL address of the mocked API endpoint + * @param delay - Delay of the response in milliseconds + */ + onPatch(url: string, delay?: number): FuseMockApiHandler + { + return this._registerHandler('patch', url, delay); + } + + /** + * Register DELETE request handler + * + * @param url - URL address of the mocked API endpoint + * @param delay - Delay of the response in milliseconds + */ + onDelete(url: string, delay?: number): FuseMockApiHandler + { + return this._registerHandler('delete', url, delay); + } + + /** + * Register PUT request handler * * @param url - URL address of the mocked API endpoint * @param delay - Delay of the response in milliseconds @@ -140,6 +143,39 @@ export class FuseMockApiService return this._registerHandler('put', url, delay); } + /** + * Register HEAD request handler + * + * @param url - URL address of the mocked API endpoint + * @param delay - Delay of the response in milliseconds + */ + onHead(url: string, delay?: number): FuseMockApiHandler + { + return this._registerHandler('head', url, delay); + } + + /** + * Register JSONP request handler + * + * @param url - URL address of the mocked API endpoint + * @param delay - Delay of the response in milliseconds + */ + onJsonp(url: string, delay?: number): FuseMockApiHandler + { + return this._registerHandler('jsonp', url, delay); + } + + /** + * Register OPTIONS request handler + * + * @param url - URL address of the mocked API endpoint + * @param delay - Delay of the response in milliseconds + */ + onOptions(url: string, delay?: number): FuseMockApiHandler + { + return this._registerHandler('options', url, delay); + } + // ----------------------------------------------------------------------------------------------------- // @ Private methods // ----------------------------------------------------------------------------------------------------- diff --git a/src/@fuse/lib/mock-api/mock-api.types.ts b/src/@fuse/lib/mock-api/mock-api.types.ts index 4a3afdb5..77236aa2 100644 --- a/src/@fuse/lib/mock-api/mock-api.types.ts +++ b/src/@fuse/lib/mock-api/mock-api.types.ts @@ -8,6 +8,9 @@ export type FuseMockApiReplyCallback = export type FuseMockApiMethods = | 'get' | 'post' - | 'put' | 'patch' - | 'delete'; + | 'delete' + | 'put' + | 'head' + | 'jsonp' + | 'options';