🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
50
node_modules/astro/dist/core/request.js
generated
vendored
Normal file
50
node_modules/astro/dist/core/request.js
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { warn } from "./logger/core.js";
|
||||
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
||||
const clientLocalsSymbol = Symbol.for("astro.locals");
|
||||
function createRequest({
|
||||
url,
|
||||
headers,
|
||||
clientAddress,
|
||||
method = "GET",
|
||||
body = void 0,
|
||||
logging,
|
||||
ssr,
|
||||
locals
|
||||
}) {
|
||||
let headersObj = headers instanceof Headers ? headers : new Headers(Object.entries(headers));
|
||||
const request = new Request(url.toString(), {
|
||||
method,
|
||||
headers: headersObj,
|
||||
body
|
||||
});
|
||||
Object.defineProperties(request, {
|
||||
params: {
|
||||
get() {
|
||||
warn(logging, "deprecation", `Astro.request.params has been moved to Astro.params`);
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!ssr) {
|
||||
const _headers = request.headers;
|
||||
const headersDesc = Object.getOwnPropertyDescriptor(request, "headers") || {};
|
||||
Object.defineProperty(request, "headers", {
|
||||
...headersDesc,
|
||||
get() {
|
||||
warn(
|
||||
logging,
|
||||
"ssg",
|
||||
`Headers are not exposed in static (SSG) output mode. To enable headers: set \`output: "server"\` in your config file.`
|
||||
);
|
||||
return _headers;
|
||||
}
|
||||
});
|
||||
} else if (clientAddress) {
|
||||
Reflect.set(request, clientAddressSymbol, clientAddress);
|
||||
}
|
||||
Reflect.set(request, clientLocalsSymbol, locals ?? {});
|
||||
return request;
|
||||
}
|
||||
export {
|
||||
createRequest
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue