Skip to content

Commit b87c5cd

Browse files
vil02RebeccaTamachiro
authored andcommitted
Remove trailing spaces (#21764)
1 parent 66d60c2 commit b87c5cd

23 files changed

+113
-113
lines changed

src/content/docs/workers/examples/alter-headers.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def on_fetch(request):
9090

9191
# Add a custom header with a value
9292
new_headers["x-workers-hello"] = "Hello from Cloudflare Workers"
93-
93+
9494
# Delete headers
9595
if "x-header-to-delete" in new_headers:
9696
del new_headers["x-header-to-delete"]
@@ -113,27 +113,27 @@ const app = new Hono();
113113
app.use('*', async (c, next) => {
114114
// Process the request with the next middleware/handler
115115
await next();
116-
116+
117117
// After the response is generated, we can modify its headers
118-
118+
119119
// Add a custom header with a value
120120
c.res.headers.append(
121121
"x-workers-hello",
122122
"Hello from Cloudflare Workers with Hono"
123123
);
124-
124+
125125
// Delete headers
126126
c.res.headers.delete("x-header-to-delete");
127127
c.res.headers.delete("x-header2-to-delete");
128-
128+
129129
// Adjust the value for an existing header
130130
c.res.headers.set("x-header-to-change", "NewValue");
131131
});
132132

133133
app.get('*', async (c) => {
134134
// Fetch content from example.com
135135
const response = await fetch("https://example.com");
136-
136+
137137
// Return the response body with original headers
138138
// (our middleware will modify the headers before sending)
139139
return new Response(response.body, {

src/content/docs/workers/examples/auth-with-headers.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ app.use('*', async (c, next) => {
109109
*/
110110
const PRESHARED_AUTH_HEADER_KEY = "X-Custom-PSK";
111111
const PRESHARED_AUTH_HEADER_VALUE = "mypresharedkey";
112-
112+
113113
// Get the pre-shared key from the request header
114114
const psk = c.req.header(PRESHARED_AUTH_HEADER_KEY);
115115

src/content/docs/workers/examples/cache-using-fetch.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ const app = new Hono<{ Bindings: Bindings }>();
8787

8888
app.all('*', async (c) => {
8989
const url = new URL(c.req.url);
90-
90+
9191
// Only use the path for the cache key, removing query strings
9292
// and always store using HTTPS, for example, https://www.example.com/file-uri-here
9393
const someCustomKey = `https://${url.hostname}${url.pathname}`;
94-
94+
9595
// Fetch the request with custom cache settings
9696
let response = await fetch(c.req.raw, {
9797
cf: {
@@ -103,13 +103,13 @@ app.all('*', async (c) => {
103103
cacheKey: someCustomKey,
104104
},
105105
});
106-
106+
107107
// Reconstruct the Response object to make its headers mutable
108108
response = new Response(response.body, response);
109-
109+
110110
// Set cache control headers to cache on browser for 25 minutes
111111
response.headers.set("Cache-Control", "max-age=1500");
112-
112+
113113
return response;
114114
});
115115

@@ -278,17 +278,17 @@ const app = new Hono<{ Bindings: Bindings }>();
278278
app.all('*', async (c) => {
279279
const originalUrl = c.req.url;
280280
const url = new URL(originalUrl);
281-
281+
282282
// Randomly select a storage backend
283283
if (Math.random() < 0.5) {
284284
url.hostname = "example.s3.amazonaws.com";
285285
} else {
286286
url.hostname = "example.storage.googleapis.com";
287287
}
288-
288+
289289
// Create a new request to the selected backend
290290
const newRequest = new Request(url, c.req.raw);
291-
291+
292292
// Fetch using the original URL as the cache key
293293
return fetch(newRequest, {
294294
cf: { cacheKey: originalUrl },

src/content/docs/workers/examples/country-code-redirect.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ app.get('*', async (c) => {
127127

128128
// Cast the raw request to include Cloudflare-specific properties
129129
const request = c.req.raw as RequestWithCf;
130-
130+
131131
// Use the cf object to obtain the country of the request
132132
// more on the cf object: https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties
133133
const country = request.cf.country;

src/content/docs/workers/examples/cron-trigger.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ app.get('/', (c) => c.text('Hello World!'));
4949
export default {
5050
// The Hono app handles regular HTTP requests
5151
fetch: app.fetch,
52-
52+
5353
// The scheduled function handles Cron triggers
5454
async scheduled(
5555
controller: ScheduledController,
5656
env: Env,
5757
ctx: ExecutionContext,
5858
) {
5959
console.log("cron processed");
60-
60+
6161
// You could also perform actions like:
6262
// - Fetching data from external APIs
6363
// - Updating KV or Durable Object storage

src/content/docs/workers/examples/data-loss-prevention.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,30 +258,30 @@ async function postDataBreach(request: Request) {
258258
app.use('*', async (c) => {
259259
// Fetch the origin response
260260
const response = await fetch(c.req.raw);
261-
261+
262262
// Return origin response if response wasn't text
263263
const contentType = response.headers.get("content-type") || "";
264264
if (!contentType.toLowerCase().includes("text/")) {
265265
return response;
266266
}
267-
267+
268268
// Get the response text
269269
let text = await response.text();
270-
270+
271271
// When debugging, replace the response from the origin with an email
272272
text = DEBUG
273273
? text.replace("You may use this", "[email protected] may use this")
274274
: text;
275-
275+
276276
// Check for sensitive data
277277
for (const kind in sensitiveRegexsMap) {
278278
const sensitiveRegex = new RegExp(sensitiveRegexsMap[kind], "ig");
279279
const match = sensitiveRegex.test(text);
280-
280+
281281
if (match) {
282282
// Alert a data breach
283283
await postDataBreach(c.req.raw);
284-
284+
285285
// Respond with a block if credit card, otherwise replace sensitive text with `*`s
286286
if (kind === "creditCard") {
287287
return c.text(`${kind} found\nForbidden\n`, 403);
@@ -294,7 +294,7 @@ app.use('*', async (c) => {
294294
}
295295
}
296296
}
297-
297+
298298
// Return the modified response
299299
return new Response(text, {
300300
status: response.status,

src/content/docs/workers/examples/debugging-logs.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ app.use('*', async (c, next) => {
168168
try {
169169
// Process the request with the next handler
170170
await next();
171-
171+
172172
// After processing, check if the response indicates an error
173173
if (c.res && (!c.res.ok && !c.res.redirected)) {
174174
const body = await c.res.clone().text();
@@ -180,28 +180,28 @@ app.use('*', async (c, next) => {
180180
body.trim().substring(0, 10)
181181
);
182182
}
183-
183+
184184
} catch (err) {
185185
// Without waitUntil, the fetch to the logging service may not complete
186186
c.executionCtx.waitUntil(
187187
postLog(err.toString())
188188
);
189-
189+
190190
// Get the error stack or error itself
191191
const stack = JSON.stringify(err.stack) || err.toString();
192-
192+
193193
// Create a new response with the error information
194-
const response = c.res ?
194+
const response = c.res ?
195195
new Response(stack, {
196196
status: c.res.status,
197197
headers: c.res.headers
198-
}) :
198+
}) :
199199
new Response(stack, { status: 500 });
200-
200+
201201
// Add debug headers
202202
response.headers.set("X-Debug-stack", stack);
203203
response.headers.set("X-Debug-err", err.toString());
204-
204+
205205
// Set the modified response
206206
c.res = response;
207207
}

src/content/docs/workers/examples/extract-cookie-value.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ const app = new Hono();
8484
app.get('*', (c) => {
8585
// The name of the cookie
8686
const COOKIE_NAME = "__uid";
87-
87+
8888
// Get the specific cookie value using Hono's cookie helper
8989
const cookieValue = getCookie(c, COOKIE_NAME);
90-
90+
9191
if (cookieValue) {
9292
// Respond with the cookie value
9393
return c.text(cookieValue);
9494
}
95-
95+
9696
return c.text("No cookie with name: " + COOKIE_NAME);
9797
});
9898

src/content/docs/workers/examples/fetch-json.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ app.get('*', async (c) => {
113113
async function gatherResponse(response: Response) {
114114
const { headers } = response;
115115
const contentType = headers.get("content-type") || "";
116-
116+
117117
if (contentType.includes("application/json")) {
118118
return { contentType, result: JSON.stringify(await response.json()) };
119119
}
120-
120+
121121
return { contentType, result: await response.text() };
122122
}
123123

src/content/docs/workers/examples/geolocation-app-weather.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,18 @@ app.get('*', async (c) => {
149149
// Get API endpoint
150150
let endpoint = "https://api.waqi.info/feed/geo:";
151151
const token = ""; // Use a token from https://aqicn.org/api/
152-
152+
153153
// Define styles
154154
const html_style = `body{padding:6em; font-family: sans-serif;} h1{color:#f6821f}`;
155-
155+
156156
// Get geolocation from Cloudflare request
157157
const req = c.req.raw;
158158
const latitude = req.cf?.latitude;
159159
const longitude = req.cf?.longitude;
160-
160+
161161
// Create complete API endpoint with coordinates
162162
endpoint += `${latitude};${longitude}/?token=${token}`;
163-
163+
164164
// Fetch weather data
165165
const init = {
166166
headers: {
@@ -169,7 +169,7 @@ app.get('*', async (c) => {
169169
};
170170
const response = await fetch(endpoint, init);
171171
const content = await response.json() as WeatherApiResponse;
172-
172+
173173
// Build HTML content
174174
const weatherContent = html`
175175
<h1>Weather 🌦</h1>
@@ -181,7 +181,7 @@ app.get('*', async (c) => {
181181
<p>The O3 level is: ${content.data.iaqi.o3?.v}.</p>
182182
<p>The temperature is: ${content.data.iaqi.t?.vC.</p>
183183
`;
184-
184+
185185
// Complete HTML document
186186
const htmlDocument = html`
187187
<!DOCTYPE html>
@@ -195,7 +195,7 @@ app.get('*', async (c) => {
195195
</div>
196196
</body>
197197
`;
198-
198+
199199
// Return HTML response
200200
return c.html(htmlDocument);
201201
});

0 commit comments

Comments
 (0)