File tree 11 files changed +3412
-0
lines changed
11 files changed +3412
-0
lines changed Original file line number Diff line number Diff line change 13
13
- [ A/B Testing using Cookies] ( ./samples/ab-testing-cookie/ )
14
14
- [ A/B Testing using Key-Value Store] ( ./samples/ab-testing-kv/ )
15
15
- [ A/B Testing using HTTP Headers (e.g User Agent)] ( ./samples/ab-testing-user-agent/ )
16
+ - [ Alter Response Headers] ( ./samples/alter-headers/ )
16
17
- [ Auto-Complete API] ( ./samples/auto-complete/e/ )
17
18
- [ Traffic Filtering: Block By IP address] ( ./samples/block-by-ip/ )
18
19
- [ Traffic Filtering: Block By user country] ( ./samples/block-by-country/ )
Original file line number Diff line number Diff line change
1
+ node_modules
2
+ dist
3
+ target
4
+ .spin /
5
+ build /
Original file line number Diff line number Diff line change
1
+ KNITWIT_SOURCE = ./config/knitwit.json
Original file line number Diff line number Diff line change
1
+ # Altering response headers
2
+
3
+ This sample shows how to alter the headers as you stream a response from an origin
4
+ server back to a client.
5
+
6
+ You can set the origin site via the ` origin_host ` variable, either by editing ` spin.toml `
7
+ or by overriding it on the command line:
8
+
9
+ ```
10
+ SPIN_VARIABLE_ORIGIN_HOST=example.com spin up --build
11
+ ```
12
+
13
+ (Note this should _ not_ include the ` https:// ` prefix - just the host name.)
14
+
15
+ The path on the origin site is taken unchanged from the request.
16
+
17
+ ## Try it out
18
+
19
+ The sample defaults to a "random facts" origin site. To try it out, ` cd ` into the
20
+ ` alter-headers ` directory and run ` spin up --build ` . Then you can ` curl ` the
21
+ ` /animals/json ` route, and use the ` -i ` option to see the altered response headers:
22
+
23
+ ```
24
+ $ curl -i localhost:3000/animals/json
25
+ HTTP/1.1 200 OK
26
+ content-length: 77
27
+ date: the eleventy-sixth of June
28
+ friendly-message: Hello from FWF
29
+
30
+ {"timestamp":1740943712057,"fact":"Sharks lay the biggest eggs in the world"}
31
+ ```
Original file line number Diff line number Diff line change
1
+ {
2
+ "version" : 1 ,
3
+ "project" : {
4
+ "worlds" : [
5
+ " spin-http"
6
+ ]
7
+ },
8
+ "packages" : {
9
+ "@fermyon/spin-sdk" : {
10
+ "witPath" : " ../../bin/wit" ,
11
+ "world" : " spin-imports"
12
+ }
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments