Create the Hello World code bundle
Your Hello World code bundle must contain the main.js
and bundle.json
files. See code bundle format for more information.
-
Create a folder on your computer for the code bundle files.
-
Go to the EdgeWorkers GitHub repository and download the
main.js
andbundle.json
files from the helloworld project or create them using the values below. -
Use the Hello World code sample to create the JavaScript source in a file called
main.js
.
When you start creating your own EdgeWorkers functions you can use the built-in Code bundle editor to validate and edit your
bundle.json
andmain.js
files.
// Hello World Example
export function onClientRequest(request) {
request.respondWith(
200, {},
'<html><body><h1>Hello World From Akamai EdgeWorkers</h1></body></html>');
}
export function onClientResponse(request, response) {
response.setHeader('X-Hello-World', 'From Akamai EdgeWorkers');
}
Each time you want to activate a new EdgeWorkers code bundle or update an existing EdgeWorkers code bundle you need to create a new version number.
- Compress the files into a code bundle.
tar -czvf filename.tgz main.js bundle.json
- Next, follow these instructions to deploy the Hello World code bundle.
Updated over 3 years ago