Code examples in AssemblyScript
These code examples have an implementation in AssemblyScript. To learn more about using AssemblyScript with our Compute@Edge platform, see using AssemblyScript.
NOTE: Some of the code examples here are also available in languages other than AssemblyScript. Being able to see how the same solution can be achieved in other languages is often useful for migrations or learning, so where a code example has multiple implementations, we show all implementations together.
Add a new field to a JSON response
Decorate API responses in JSON format with new fields.
Use microservices to divide up a domain
Send request to different origin servers based on the URL path.
Serve robots.txt from the edge
Serve full text of robots.txt as a synthetic response to avoid requests hitting your origin.
Rewrite URL path
Receive a request for one path but request a different path from origin, without a redirect.
Perform multiple origin requests asynchronously
Handle third-party requests as they are resolved.
All code on this page is provided under both the BSD and MIT open source licenses.