[ci] format
This commit is contained in:
parent
61e1a267a8
commit
b5b95e4fb4
5 changed files with 11 additions and 9 deletions
|
@ -132,16 +132,16 @@ export interface AstroGlobal extends AstroGlobalPartial {
|
||||||
*/
|
*/
|
||||||
request: Request;
|
request: Request;
|
||||||
/** Information about the outgoing response. This is a standard [ResponseInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#init) object
|
/** Information about the outgoing response. This is a standard [ResponseInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#init) object
|
||||||
*
|
*
|
||||||
* For example, to change the status code you can set a different status on this object:
|
* For example, to change the status code you can set a different status on this object:
|
||||||
* ```typescript
|
* ```typescript
|
||||||
* Astro.response.status = 404;
|
* Astro.response.status = 404;
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroresponse)
|
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroresponse)
|
||||||
*/
|
*/
|
||||||
response: ResponseInit & {
|
response: ResponseInit & {
|
||||||
readonly headers: Headers
|
readonly headers: Headers;
|
||||||
};
|
};
|
||||||
/** Redirect to another page (**SSR Only**)
|
/** Redirect to another page (**SSR Only**)
|
||||||
*
|
*
|
||||||
|
|
|
@ -112,7 +112,7 @@ export class App {
|
||||||
let headers = init.headers as Headers;
|
let headers = init.headers as Headers;
|
||||||
let bytes = this.#encoder.encode(html);
|
let bytes = this.#encoder.encode(html);
|
||||||
headers.set('Content-Type', 'text/html');
|
headers.set('Content-Type', 'text/html');
|
||||||
headers.set('Content-Length', bytes.byteLength.toString())
|
headers.set('Content-Length', bytes.byteLength.toString());
|
||||||
return new Response(bytes, init);
|
return new Response(bytes, init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,9 @@ export interface RenderOptions {
|
||||||
|
|
||||||
export async function render(
|
export async function render(
|
||||||
opts: RenderOptions
|
opts: RenderOptions
|
||||||
): Promise<{ type: 'html'; html: string, response: ResponseInit; } | { type: 'response'; response: Response }> {
|
): Promise<
|
||||||
|
{ type: 'html'; html: string; response: ResponseInit } | { type: 'response'; response: Response }
|
||||||
|
> {
|
||||||
const {
|
const {
|
||||||
links,
|
links,
|
||||||
logging,
|
logging,
|
||||||
|
@ -162,6 +164,6 @@ export async function render(
|
||||||
return {
|
return {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
html,
|
html,
|
||||||
response: result.response
|
response: result.response,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ export interface SSROptions {
|
||||||
export type ComponentPreload = [SSRLoadedRenderer[], ComponentInstance];
|
export type ComponentPreload = [SSRLoadedRenderer[], ComponentInstance];
|
||||||
|
|
||||||
export type RenderResponse =
|
export type RenderResponse =
|
||||||
| { type: 'html'; html: string, response: ResponseInit }
|
| { type: 'html'; html: string; response: ResponseInit }
|
||||||
| { type: 'response'; response: Response };
|
| { type: 'response'; response: Response };
|
||||||
|
|
||||||
const svelteStylesRE = /svelte\?svelte&type=style/;
|
const svelteStylesRE = /svelte\?svelte&type=style/;
|
||||||
|
|
|
@ -104,7 +104,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
|
||||||
|
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const canonicalURL = createCanonicalURL('.' + pathname, site ?? url.origin);
|
const canonicalURL = createCanonicalURL('.' + pathname, site ?? url.origin);
|
||||||
const response: ResponseInit = {
|
const response: ResponseInit = {
|
||||||
status: 200,
|
status: 200,
|
||||||
statusText: 'OK',
|
statusText: 'OK',
|
||||||
headers: new Headers(),
|
headers: new Headers(),
|
||||||
|
@ -215,7 +215,7 @@ ${extra}`
|
||||||
renderers,
|
renderers,
|
||||||
pathname,
|
pathname,
|
||||||
},
|
},
|
||||||
response
|
response,
|
||||||
};
|
};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue