|
1 | 1 | import { HTTP_EXCHANGE_METADATA } from './constants'; |
2 | 2 | import { HttpRequestBuilder } from '../builders/http-request.builder'; |
3 | | -import { type AsyncFunction, type HttpMethod } from '../types'; |
| 3 | +import { |
| 4 | + type AsyncFunction, |
| 5 | + type HttpClientOptions, |
| 6 | + type HttpMethod, |
| 7 | +} from '../types'; |
4 | 8 |
|
5 | 9 | export const HttpExchange = |
6 | | - (method: HttpMethod, url: string) => |
| 10 | + (method: HttpMethod, url: string, options?: HttpClientOptions) => |
7 | 11 | <P extends string>(target: Record<P, AsyncFunction>, propertyKey: P) => { |
8 | 12 | Reflect.defineMetadata( |
9 | 13 | HTTP_EXCHANGE_METADATA, |
10 | | - new HttpRequestBuilder(target, propertyKey, method, url), |
| 14 | + new HttpRequestBuilder( |
| 15 | + target, |
| 16 | + propertyKey, |
| 17 | + method, |
| 18 | + url, |
| 19 | + undefined, |
| 20 | + options, |
| 21 | + ), |
11 | 22 | target, |
12 | 23 | propertyKey, |
13 | 24 | ); |
14 | 25 | }; |
15 | 26 |
|
16 | 27 | /* eslint-disable @typescript-eslint/explicit-function-return-type */ |
17 | | -export const GetExchange = (url = '') => HttpExchange('GET', url); |
18 | | -export const PostExchange = (url = '') => HttpExchange('POST', url); |
19 | | -export const PutExchange = (url = '') => HttpExchange('PUT', url); |
20 | | -export const DeleteExchange = (url = '') => HttpExchange('DELETE', url); |
21 | | -export const PatchExchange = (url = '') => HttpExchange('PATCH', url); |
22 | | -export const HeadExchange = (url = '') => HttpExchange('HEAD', url); |
23 | | -export const OptionsExchange = (url = '') => HttpExchange('OPTIONS', url); |
| 28 | +export const GetExchange = (url = '', options?: HttpClientOptions) => |
| 29 | + HttpExchange('GET', url, options); |
| 30 | +export const PostExchange = (url = '', options?: HttpClientOptions) => |
| 31 | + HttpExchange('POST', url, options); |
| 32 | +export const PutExchange = (url = '', options?: HttpClientOptions) => |
| 33 | + HttpExchange('PUT', url, options); |
| 34 | +export const DeleteExchange = (url = '', options?: HttpClientOptions) => |
| 35 | + HttpExchange('DELETE', url, options); |
| 36 | +export const PatchExchange = (url = '', options?: HttpClientOptions) => |
| 37 | + HttpExchange('PATCH', url, options); |
| 38 | +export const HeadExchange = (url = '', options?: HttpClientOptions) => |
| 39 | + HttpExchange('HEAD', url, options); |
| 40 | +export const OptionsExchange = (url = '', options?: HttpClientOptions) => |
| 41 | + HttpExchange('OPTIONS', url, options); |
0 commit comments