-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This function handles default requests | ||
* | ||
* @returns The default response | ||
*/ | ||
export default function defaultHandler() : Response { | ||
return new Response( | ||
"Not found", | ||
{ status: 404 } | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { serveFile } from '@std/http/file-server'; | ||
|
||
/** | ||
* This function handles requests for page assets. | ||
* | ||
* @param request The request from the client | ||
* @param page The requested page | ||
* @param path The path to the asset that was requested | ||
* @returns The asset response | ||
*/ | ||
export default function pageAssetsHandler( | ||
request : Request, | ||
page : string | undefined, | ||
path : string | undefined | ||
) : Promise<Response> { | ||
return serveFile( | ||
request, | ||
`./dist/route/${page}/${path}` | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { serveFile } from '@std/http/file-server'; | ||
|
||
/** | ||
* This function handles page requests. | ||
* | ||
* @param request The request from the client | ||
* @param page The requested page | ||
* @param defaultFile The default file to serve | ||
* @returns The page response | ||
*/ | ||
export default function pageHandler( | ||
request : Request, | ||
page : string | undefined, | ||
defaultFile = 'index.html' | ||
) : Promise<Response> { | ||
return serveFile( | ||
request, | ||
`./dist/route/${page}/${defaultFile}` | ||
) | ||
} |