docs(dotnet): route examples (#6578)
This commit is contained in:
parent
2477dccee9
commit
ec0b4e9061
|
|
@ -84,6 +84,15 @@ def handle(route, request):
|
||||||
page.route("**/*", handle)
|
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
|
### option: Route.continue.url
|
||||||
- `url` <[string]>
|
- `url` <[string]>
|
||||||
|
|
||||||
|
|
@ -143,6 +152,13 @@ page.route("**/*", lambda route: route.fulfill(
|
||||||
body="not found!"))
|
body="not found!"))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
await page.RouteAsync("**/*", route => route.FulfillAsync(
|
||||||
|
status: 404,
|
||||||
|
contentType: "text/plain",
|
||||||
|
body: "Not Found!"));
|
||||||
|
```
|
||||||
|
|
||||||
An example of serving static file:
|
An example of serving static file:
|
||||||
|
|
||||||
```js
|
```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"))
|
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
|
### option: Route.fulfill.status
|
||||||
- `status` <[int]>
|
- `status` <[int]>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue