MCPcopy
hub / github.com/sveltejs/kit / is_endpoint_request

Function is_endpoint_request

packages/kit/src/runtime/server/endpoint.js:94–108  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

92 * @param {import('@sveltejs/kit').RequestEvent} event
93 */
94export function is_endpoint_request(event) {
95 const { method, headers } = event.request;
96
97 // These methods exist exclusively for endpoints
98 if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) {
99 return true;
100 }
101
102 // use:enhance uses a custom header to disambiguate
103 if (method === 'POST' && headers.get('x-sveltekit-action') === 'true') return false;
104
105 // GET/POST requests may be for endpoints or pages. We prefer endpoints if this isn't a text/html request
106 const accept = event.request.headers.get('accept') ?? '*/*';
107 return negotiate(accept, ['*', 'text/html']) !== 'text/html';
108}

Callers 1

resolveFunction · 0.90

Calls 1

negotiateFunction · 0.90

Tested by

no test coverage detected