Skip to content

Commit

Permalink
feat: response return url (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-mio committed Jun 4, 2021
1 parent b3454dd commit de9ed27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/createMockServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function requestMiddleware(opt: ViteMockOptions) {
} else {
const body = await parseJson(req);
const mockResponse = isFunction(response)
? response({ body, query, headers: req.headers })
? response({ url: req.url, body, query, headers: req.headers })
: response;
res.setHeader('Content-Type', 'application/json');
res.statusCode = statusCode || 200;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export declare interface MockMethod {
method?: MethodType;
timeout?: number;
statusCode?: number;
response?: ((opt: { body: Recordable; query: Recordable; headers: Recordable }) => any) | any;
response?: ((opt: { url: Recordable, body: Recordable; query: Recordable; headers: Recordable }) => any) | any;
rawResponse?: (req: IncomingMessage, res: ServerResponse) => void;
}

Expand Down

0 comments on commit de9ed27

Please sign in to comment.