[go: nahoru, domu]

Skip to content

Commit

Permalink
chore(docs): update routing docs
Browse files Browse the repository at this point in the history
Signed-off-by: Brian H <brian.hardock@fermyon.com>
  • Loading branch information
fibonacci1729 committed Feb 6, 2023
1 parent 84a2629 commit c5b4456
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions content/spin/http-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ which means the component will be invoked for every request starting with the
`/base/bar/baz/qux/quux` and so on).

If multiple components could potentially handle the same request based on their
defined routes, the last component defined in `spin.toml` takes precedence.
In the following example:
defined routes, the component whose route has the longest matching prefix
takes precedence.

In the following example, any request starting with the `/foo/` prefix (e.g. `/foo/bar`)
will be handled by `component-1`:

```toml
# spin.toml
Expand All @@ -75,16 +78,16 @@ trigger = { type = "http", base = "/"}
[[component]]
id = "component-1"
[component.trigger]
route = "/..."
route = "/foo/..."

[[component]]
id = "component-2"
[component.trigger]
route = "/foo/..."
route = "/..."
```

Any request starting with the `/foo/` prefix will be handled by `component-2`,
which is the last one defined in `spin.toml`.
> Note: Although the route defined by `component-2` also matches `/foo/bar`, the route
> defined by `component-1` has the longer matching prefix, i.e. `/foo/`.
Every HTTP application has a special route always configured at `/.well-known/spin/health`, which
returns `OK 200` when the Spin instance is healthy.
Expand Down

0 comments on commit c5b4456

Please sign in to comment.