Skip to content

Commit

Permalink
fix(router): use default behavior for no-content handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 8, 2023
1 parent a72a4b8 commit e3c9f96
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import type { HTTPMethod, EventHandler } from "./types";
import { createError } from "./error";
import { eventHandler, toEventHandler } from "./event";
import { setResponseStatus } from "./utils";

export type RouterMethod = Lowercase<HTTPMethod>;
const RouterMethods: RouterMethod[] = [
Expand Down Expand Up @@ -151,8 +150,7 @@ export function createRouter(opts: CreateRouterOptions = {}): Router {
// Call handler
return Promise.resolve(handler(event)).then((res) => {
if (res === undefined && (opts.preemptive || opts.preemtive)) {
setResponseStatus(event, 204);
return "";
return null; // Send empty content
}
return res;
});
Expand Down

0 comments on commit e3c9f96

Please sign in to comment.