feature: serverus modularly serves up a directory as an HTTP server
This commit is contained in:
commit
58139b078d
20 changed files with 1449 additions and 0 deletions
8
tests/www/echo/___input/index.ts
Normal file
8
tests/www/echo/___input/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export function GET(_req: Request, meta: Record<string, any>): Response {
|
||||
return new Response(meta.params.input ?? '', {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
});
|
||||
}
|
22
tests/www/permissions/test.ts
Normal file
22
tests/www/permissions/test.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
export const PRECHECKS: Record<string, (req: Request, meta: Record<string, any>) => Promise<Response | undefined> | Response | undefined> =
|
||||
{};
|
||||
|
||||
PRECHECKS.GET = (request: Request, _meta: Record<string, any>): Response | undefined => {
|
||||
const secret = request.headers.get('x-secret');
|
||||
if (secret !== 'very secret') {
|
||||
return new Response('Permission Denied', {
|
||||
status: 400,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
export function GET(_req: Request, _meta: Record<string, any>): Response {
|
||||
return new Response('this is secret', {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
});
|
||||
}
|
3
tests/www/test.md
Normal file
3
tests/www/test.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# test
|
||||
|
||||
## this is the test
|
1
tests/www/test.txt
Normal file
1
tests/www/test.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this is a test
|
Loading…
Add table
Add a link
Reference in a new issue