From ec0b4e90614a6296b455bfba31c164f70f021777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20Vodovnik?= Date: Fri, 14 May 2021 16:49:14 +0200 Subject: [PATCH] docs(dotnet): route examples (#6578) --- docs/src/api/class-route.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/src/api/class-route.md b/docs/src/api/class-route.md index 0b33a5f930..19db4c58ec 100644 --- a/docs/src/api/class-route.md +++ b/docs/src/api/class-route.md @@ -84,6 +84,15 @@ def handle(route, request): page.route("**/*", handle) ``` +```csharp +await page.RouteAsync("**/*", route => +{ + var headers = new Dictionary(route.Request.Headers) { { "foo", "bar" } }; + headers.Remove("origin"); + route.ResumeAsync(headers); +}); +``` + ### option: Route.continue.url - `url` <[string]> @@ -143,6 +152,13 @@ page.route("**/*", lambda route: route.fulfill( body="not found!")) ``` +```csharp +await page.RouteAsync("**/*", route => route.FulfillAsync( + status: 404, + contentType: "text/plain", + body: "Not Found!")); +``` + An example of serving static file: ```js @@ -162,6 +178,10 @@ await page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data. page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json")) ``` +```csharp +await page.RouteAsync("**/xhr_endpoint", route => route.FulfillAsync(path: "mock_data.json")); +``` + ### option: Route.fulfill.status - `status` <[int]>