Azion Edge Functions supports JavaScript handlers. Handler functions let you control how your edge logic manages incoming requests, applies security rules, and interacts with the runtime environment. You can define handler functions by using either the ES Modules pattern or the Service Worker syntax.
With Javascript Handlers you can:
Respond to fetch (HTTP request) events.
Apply firewall and access control logic.
Perform asynchronous operations during request processing.
exportdefault{
asyncfetch(request, env, ctx){
returnnewResponse('Hello World!');
},
};
Parameters:
Parameter
Type
Description
request
Request
HTTP request object
env
Object
Environment variables and bindings
ctx
Object
Execution context
ctx.waitUntil(promise)
Function
Extends the worker’s lifetime
exportdefault{
asyncfirewall(request, env, ctx){
returnnewResponse('Hello World!');
},
};
Parameters:
Parameter
Type
Description
request
Request
HTTP request object
env
Object
Environment variables and bindings
ctx
Object
Execution context
ctx.deny()
Function
Blocks the request immediately (ES Modules pattern only). If not called, the request continues to the fetch handler