A starter Spin application written in TypeScript, created from the http-ts template. It answers every GET request with a plain-text greeting, which makes it a good first step on Akamai Functions.
Recreate it locally with:
spin new -t http-ts -a hello-ts
A starter Spin application written in Rust, created from the http-rust template and extended to read JSON. POST a body like {"name": "Developer"} to /greet and it answers with a JSON greeting. Uses serde and serde_json for (de)serialization.
Recreate the starting point locally with:
spin new -t http-rust -a hello-rust
Fetches an HTML page from an origin and rewrites it on the fly while streaming it to the client: every <li> element gets the prefix "Iced ". Bytes are forwarded as soon as they are rewritten, so the page is never buffered in full.
Crates used:
spin-sdk: HTTP handler and outbound request to the origin
lol_html: streaming HTML rewriting
futures: stream handling
anyhow: error handling
A starter Spin application written in JavaScript, created from the http-js template. It answers every GET request with a plain-text greeting, which makes it a good first step on Akamai Functions.
Recreate it locally with:
spin new -t http-js -a hello-js
A starter Spin application written in Go, created from the http-go template. It answers every GET request with a plain-text greeting, which makes it a good first step on Akamai Functions.
Recreate it locally with:
spin new -t http-go -a hello-go
A starter Spin application written in Python, created from the http-py template. It answers every GET request with a plain-text greeting, which makes it a good first step on Akamai Functions.
Recreate it locally with:
spin new -t http-py -a hello-python
A small proxy in front of an origin, by default the Star Wars API. Every GET request is forwarded to the origin with the same path and query string, passing on the client's accept header (*/* when missing). The response keeps the origin's status, body and content-type, drops every other origin header and adds a custom x-intercepted-value: foobar header.
The origin comes from the Spin variable origin, read on each request, so the proxy can point somewhere else without code changes.
APIs and packages used:
fetch: outbound request to the origin
@spinframework/spin-variables: reads the origin variable
A small proxy in front of an origin, by default the Star Wars API. Every GET request is forwarded to the origin with the same path and query string, passing on the client's accept header (*/* when missing). The response keeps the origin's status, body and content-type, drops every other origin header and adds a custom x-intercepted-value: foobar header.
The origin comes from the Spin variable origin, read on each request, so the proxy can point somewhere else without code changes.
Crates used:
spin-sdk: HTTP handler, Spin variables and the outbound request to the origin
anyhow: error handling
A small proxy in front of an origin, by default the Star Wars API. Every GET request is forwarded to the origin with the same path and query string, passing on the client's accept header (*/* when missing). The response keeps the origin's status, body and content-type, drops every other origin header and adds a custom x-intercepted-value: foobar header.
The origin comes from the Spin variable origin, read on each request, so the proxy can point somewhere else without code changes.
Packages used:
github.com/spinframework/spin-go-sdk/v3/http: HTTP handler and outbound request to the origin
github.com/spinframework/spin-go-sdk/v3/variables: reads the origin variable
Fetches a character from the Star Wars API and returns its JSON unchanged. GET / returns Luke Skywalker, and GET /people/<id> returns any character by numeric id. A non-numeric id gets a 400 and any other path a 404, both with a small JSON error body.
APIs used:
fetch: outbound HTTP request
URL: path parsing, no router library
Fetches a character from the Star Wars API and returns its JSON unchanged. GET / returns Luke Skywalker, and GET /people/<id> returns any character by numeric id. A non-numeric id gets a 400 and any other path a 404, both with a small JSON error body.
Crates used:
spin-sdk: HTTP handler and outbound request
serde_json: JSON error bodies
anyhow: error handling
Fetches a character from the Star Wars API and returns its JSON unchanged. GET / returns Luke Skywalker, and GET /people/<id> returns any character by numeric id. A non-numeric id gets a 400 and any other path a 404, both with a small JSON error body.
Packages used:
github.com/spinframework/spin-go-sdk/v3/http: HTTP handler and outbound GET request
regexp / strings (standard library): routing and id validation
Sends two requests to the Star Wars API concurrently, one for a person and one for a planet, and combines one field from each into a single JSON response: {"person":"Luke Skywalker","planet":"Tatooine"}. Because both run at the same time, the total latency is about that of the slower call. If either upstream request fails, the app answers 502.
APIs used:
fetch: outbound HTTP requests
Promise.all: runs both requests concurrently
Sends two requests to the Star Wars API concurrently, one for a person and one for a planet, and combines one field from each into a single JSON response: {"person":"Luke Skywalker","planet":"Tatooine"}. Because both run at the same time, the total latency is about that of the slower call. If either upstream request fails, the app answers 502.
Crates used:
spin-sdk: HTTP handler and outbound requests
futures: join! runs both requests concurrently
serde / serde_json: (de)serialization
anyhow: error handling
Sends two requests to the Star Wars API concurrently, one for a person and one for a planet, and combines one field from each into a single JSON response: {"person":"Luke Skywalker","planet":"Tatooine"}. Because both run at the same time, the total latency is about that of the slower call. If either upstream request fails, the app answers 502.
Packages used:
github.com/spinframework/spin-go-sdk/v3/http: HTTP handler and outbound GET requests
sync (standard library): two goroutines joined with a WaitGroup
encoding/json (standard library): (de)serialization