docs: add subtitles to concepts/routes (#554)

This commit is contained in:
ahuigo
2022-07-30 15:05:55 +00:00
committed by GitHub
parent 0595f92ab8
commit 39309e4c22
+6
View File
@@ -20,6 +20,8 @@ determine exactly what should be rendered. By default components receives props
consisting of: the request URL, the matches from the URL pattern match, and any
data passed to the handler's `render` function.
## Handler route
Let's look at a basic route that returns a plain text string:
```tsx
@@ -41,6 +43,8 @@ handler above is called for `GET` requests. If the handler is a function, it is
called for all requests regardless of the method. If an HTTP method does not
have a corresponding handler, a 405 HTTP error is returned.
## Component route
Now, let's render some HTML using the route component:
```tsx
@@ -63,6 +67,8 @@ default handler is used that just renders out the page component if present. You
can also override the default handler though to modify how exactly rendering
should work.
## Mixed handler and component route
In the below example, a custom handler is used to add a custom header to the
response after rendering the page component.