docs(dotnet): route examples (#6578)

This commit is contained in:
Anže Vodovnik 2021-05-14 16:49:14 +02:00 committed by GitHub
parent 2477dccee9
commit ec0b4e9061
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,6 +84,15 @@ def handle(route, request):
page.route("**/*", handle)
```
```csharp
await page.RouteAsync("**/*", route =>
{
var headers = new Dictionary<string, string>(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]>