class Playwright::Route

Learn more about [networking](../network.md).
allows to handle the route.
Whenever a network route is set up with [‘method: Page.route`] or [`method: BrowserContext.route`], the `Route` object

def abort(errorCode: nil)

Aborts the route's request.
def abort(errorCode: nil)
  wrap_impl(@impl.abort(errorCode: unwrap_impl(errorCode)))
end

def continue(headers: nil, method: nil, postData: nil, url: nil)

```
page.route("**/*", handle)
}
route.continue_(headers=headers)
}
"bar": None # remove "bar" header
"foo": "foo-value" # set "foo" header
**request.headers,
headers = {
# override headers
def handle(route, request):
```python sync

Continues route's request with optional overrides.
def continue(headers: nil, method: nil, postData: nil, url: nil)
  wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
end

def event_emitter_proxy

def event_emitter_proxy
_emitter_proxy ||= EventEmitterProxy.new(self, @impl)

def fallback(headers: nil, method: nil, postData: nil, url: nil)

```
page.route("**/*", handle)
}
route.fallback(headers=headers)
}
"bar": None # remove "bar" header
"foo": "foo-value" # set "foo" header
**request.headers,
headers = {
# override headers
def handle(route, request):
```python sync

url, method, headers and postData of the request.
One can also modify request while falling back to the subsequent handler, that way intermediate route handler can modify

```
page.route("**/*", handle_post)
page.route("**/*", handle_get)

# ...
# Handling POST only.
return
route.fallback()
if route.request.method != "POST":
def handle_post(route):
# Handle POST requests.

# ...
# Handling GET only.
return
route.fallback()
if route.request.method != "GET":
def handle_post(route):
# Handle GET requests.
```python sync

API calls vs page resources or GET requests vs POST requests as in the example below.
Registering multiple routes is useful when you want separate handlers to handle different kinds of requests, for example

```
page.route("**/*", lambda route: route.fallback()) # Runs first.
page.route("**/*", lambda route: route.fallback()) # Runs second.
page.route("**/*", lambda route: route.abort()) # Runs last.
```python sync

registered route.
bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
registered route can always override all the previous ones. In the example below, request will be handled by the
When several routes match the given pattern, they run in the order opposite to their registration. That way the last
def fallback(headers: nil, method: nil, postData: nil, url: nil)
  wrap_impl(@impl.fallback(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
end

def fulfill(

```
page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
```python sync

An example of serving static file:

```
body="not found!"))
content_type="text/plain",
status=404,
page.route("**/*", lambda route: route.fulfill(
```python sync

An example of fulfilling all requests with 404 responses:

Fulfills route's request with given response.
def fulfill(
      body: nil,
      contentType: nil,
      headers: nil,
      path: nil,
      response: nil,
      status: nil)
  wrap_impl(@impl.fulfill(body: unwrap_impl(body), contentType: unwrap_impl(contentType), headers: unwrap_impl(headers), path: unwrap_impl(path), response: unwrap_impl(response), status: unwrap_impl(status)))
end

def off(event, callback)

@nodoc
-- inherited from EventEmitter --
def off(event, callback)
  event_emitter_proxy.off(event, callback)
end

def on(event, callback)

@nodoc
-- inherited from EventEmitter --
def on(event, callback)
  event_emitter_proxy.on(event, callback)
end

def once(event, callback)

@nodoc
-- inherited from EventEmitter --
def once(event, callback)
  event_emitter_proxy.once(event, callback)
end

def redirect_navigation_request(url)

@nodoc
def redirect_navigation_request(url)
  wrap_impl(@impl.redirect_navigation_request(unwrap_impl(url)))
end

def request

A request to be routed.
def request
  wrap_impl(@impl.request)
end