Skip to content

Commit

Permalink
Apply Angel's remaining feedback to the rewrite urls how to
Browse files Browse the repository at this point in the history
Signed-off-by: Diana <[email protected]>
  • Loading branch information
cloudjumpercat committed Dec 18, 2024
1 parent 7165bbc commit 81e2355
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/_gateway_entities/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Use the following table to help you understand how Routes can be configured for
| You want to... | Then use... |
|--------|----------|
| Rate limit internal and external traffic to a Service | [Enable a rate limiting plugin on Routes attached to the Service](/plugins/rate-limiting-advanced/) |
| Perform a simple URL rewrite, such as renaming your legacy `/api/old/` Upstream endpoint to a publicly accessible API endpoint that is now named `/new/api`. | [Set up a Gateway Service with the old path and a Route with new path](/how-to/dynamically-rewrite-simple-request-urls-with-routes/) |
| Perform a simple URL rewrite, such as renaming your legacy `/api/old/` Upstream endpoint to a publicly accessible API endpoint that is now named `/new/api`. | [Set up a Gateway Service with the old path and a Route with new path](/how-to/rewrite-simple-request-urls-with-routes/) |
| Perform a complex URL rewrite, such as replacing `/api/<function>/old` with `/new/api/<function>`. | [Request Transformer Advanced plugin](https://docs.konghq.com/hub/kong-inc/request-transformer-advanced/) |
| Describe Routes or paths as patterns using regular expressions. | [Expressions router](/gateway/routing/expressions/) |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ related_resources:
url: /gateway/entities/service/
- text: Routing in {{site.base_gateway}}
url: /gateway/routing/
- text: Expressions router
url: /gateway/routing/expressions/

products:
- gateway
Expand All @@ -25,8 +23,6 @@ prereqs:
entities:
services:
- example-service
routes:
- example-route

entities:
- service
Expand Down Expand Up @@ -54,23 +50,9 @@ cleanup:
icon_url: /assets/icons/gateway.svg
---

## 1. Set up a Service with the path to the old Upstream
## 1. Set up a Route with the path to the new Upstream

In the prerequisites, you created the `example-service` and `example-route` with the `/anything` path. This path, `/anything`, is your old upstream path. You must modify your existing Service to contain the old `/anything` path. By doing it this way, traffic can continue to be routed to the old path while you enable the new path.

{% entity_examples %}
entities:
services:
- name: example-service
url: http://httpbin.konghq.com/anything
append_to_existing_section: true
{% endentity_examples %}

<!--figure out apphending-->

## 2. Set up a Route with the path to the new Upstream

Now you can create a Route with your new path, `/new-path`, that points to the new Upstream.
In the prerequisites, you created the `example-service` pointing to the `/anything` upstream. This path, `/anything`, is your old upstream path. You must create a Route with your new path, `/new-path`, that points to the new Upstream. By doing it this way, traffic can continue to be routed to the old path while you enable the new path.

{% entity_examples %}
entities:
Expand All @@ -80,14 +62,13 @@ entities:
- "/new-path"
service:
name: example-service
append_to_existing_section: true
{% endentity_examples %}

## 3. Apply configuration
## 2. Apply configuration

{% include how-tos/steps/apply_config.md %}

## 4. Validate
## 3. Validate

To validate that the URL was successfully rewritten and the request is now being matched to the new Upstream instead of the old one, run the following:

Expand All @@ -103,4 +84,4 @@ curl -i http://{host}/new-path
Replace `{host}` with the proxy URL for this data plane node.
{: data-deployment-topology="konnect" }

This command should display a 200 status as you're redirected to the new URL.
This command should display a 200 status as you're redirected to the new URL. In the response, you'll also see that `"Host": "httpbin.konghq.com",` as the request is proxied to the new URL.

0 comments on commit 81e2355

Please sign in to comment.