Skip to content

Commit 809b6f7

Browse files
authored
Merge pull request #302 from louwers/patch-2
Update path.md
2 parents df7c69f + 7d6bd45 commit 809b6f7

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

docs/essential/path.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ head:
77

88
- - meta
99
- name: 'description'
10-
content: Path or pathname is an identifier to locate resources from a server. Elysia uses the path and method to look up the correct resource. Path in Elysia can be categorized into 3 types. Static, Dynamic and Wildcard.
10+
content: A path or pathname is an identifier to locate resources of a server. Elysia uses the path and method to look up the correct resource. Paths in Elysia can be categorized into 3 types: Static, Dynamic and Wildcard.
1111

1212
- - meta
1313
- property: 'og:description'
@@ -48,7 +48,7 @@ const demo4 = new Elysia()
4848

4949
# Path
5050

51-
Path or pathname is an identifier to locate resources from a server.
51+
A path or pathname is an identifier to locate resources of a server.
5252

5353
```bash
5454
http://localhost:/path/page
@@ -76,15 +76,15 @@ We can categorize the URL and path as follows:
7676
If the path is not specified, the browser and web server will treat the path as '/' as a default value.
7777
:::
7878

79-
Elysia will lookup each request for [route](/essential/route) and response using [handler](/essential/handler) function.
79+
Elysia will look up each request for [route](/essential/route) and response using [handler](/essential/handler) function.
8080

8181
## Dynamic path
8282

8383
URLs can be both static and dynamic.
8484

85-
Static path means a hardcoded string can be used to locate resources from the server while dynamic path matches some part and captures the value to extract extra information.
85+
Static paths are hardcoded strings that can be used to locate resources of the server, while dynamic paths match some part and captures the value to extract extra information.
8686

87-
For instance, we can extract the user ID from the pathname, we can do something like:
87+
For instance, we can extract the user ID from the pathname. For example:
8888

8989
```typescript twoslash
9090
import { Elysia } from 'elysia'
@@ -95,7 +95,7 @@ new Elysia()
9595
.listen(3000)
9696
```
9797

98-
We create a dynamic path with `/id/:id` which tells Elysia to match any path up until `/id` and after it could be any value, which is then stored as **params** object.
98+
Here dynamic path is created with `/id/:id` which tells Elysia to match any path up until `/id`. What comes after that is then stored as **params** object.
9999

100100
<Playground
101101
:elysia="demo1"
@@ -120,21 +120,21 @@ When requested, the server should return the response as follows:
120120
| /id | Not Found |
121121
| /id/anything/rest | Not Found |
122122

123-
Dynamic path is great to enforce the URL to contain crucial information like ID which then can be used later.
123+
Dynamic paths are great to include things like IDs, which then can be used later.
124124

125125
We refer to the named variable path as **path parameter** or **params** for short.
126126

127127
## Segment
128128

129-
URL segment is each path that is composed into a full path.
129+
URL segments are each path that is composed into a full path.
130130

131-
Segment is separated by `/`.
131+
Segments are separated by `/`.
132132
![Representation of URL segments](/essential/url-segment.webp)
133133

134134
Path parameters in Elysia are represented by prefixing a segment with ':' followed by a name.
135135
![Representation of path parameter](/essential/path-parameter.webp)
136136

137-
Path parameters allow Elysia to capture a specific segment of URL.
137+
Path parameters allow Elysia to capture a specific segment of a URL.
138138

139139
The named path parameter will then be stored in `Context.params`.
140140

@@ -144,9 +144,9 @@ The named path parameter will then be stored in `Context.params`.
144144
| /id/:id | /id/hi | id=hi |
145145
| /id/:name | /id/hi | name=hi |
146146

147-
## Multiple path parameter
147+
## Multiple path parameters
148148

149-
You can have as many path parameters as you would like, which will then be stored into a `params`.
149+
You can have as many path parameters as you like, which will then be stored into a `params` object.
150150

151151
```typescript twoslash
152152
import { Elysia } from 'elysia'
@@ -174,7 +174,7 @@ new Elysia()
174174
}"
175175
/>
176176

177-
Requesting to the server should return the response as the following:
177+
The server will respond as follows:
178178

179179
| Path | Response |
180180
| ---------------------- | ------------- |
@@ -185,13 +185,13 @@ Requesting to the server should return the response as the following:
185185
| /id | Not Found |
186186
| /id/anything/rest | anything rest |
187187

188-
## Wildcard
188+
## Wildcards
189189

190-
Dynamic path allows us to capture certain segments of the URL.
190+
Dynamic paths allow capturing certain segments of the URL.
191191

192-
However, when you need a value of the path to be more dynamic and capture the rest of the URL segment, a wildcard can be used.
192+
However, when you need a value of the path to be more dynamic and want to capture the rest of the URL segment, a wildcard can be used.
193193

194-
Wildcard can capture the value after segment regardless of amount by using "\*".
194+
Wildcards can capture the value after segment regardless of amount by using "\*".
195195

196196
```typescript twoslash
197197
import { Elysia } from 'elysia'
@@ -218,7 +218,7 @@ new Elysia()
218218
}"
219219
/>
220220

221-
Sending a request to the server should return the response as the following:
221+
In this case the server will respons as follows:
222222

223223
| Path | Response |
224224
| ---------------------- | ------------- |
@@ -229,27 +229,27 @@ Sending a request to the server should return the response as the following:
229229
| /id | Not Found |
230230
| /id/anything/rest | anything/rest |
231231

232-
A wildcard is useful for capturing a path until a specific point.
232+
Wildcards are useful for capturing a path until a specific point.
233233

234234
::: tip
235235
You can use a wildcard with a path parameter.
236236
:::
237237

238-
## Summarize
238+
## Summary
239239

240240
To summarize, the path in Elysia can be grouped into 3 types:
241241

242-
- **static path** - static string to locate the resource
243-
- **dynamic path** - segment can be any value
244-
- **wildcard** - path until a specific point can be anything
242+
- **static paths** - static string to locate the resource
243+
- **dynamic paths** - segment can be any value
244+
- **wildcards** - path until a specific point can be anything
245245

246246
You can use all of the path types together to compose a behavior for your web server.
247247

248-
The priority of the path is aligned as follows:
248+
The priorities are as follows:
249249

250-
1. static path
251-
2. dynamic path
252-
3. wildcard
250+
1. static paths
251+
2. dynamic paths
252+
3. wildcards
253253

254254
If the path is resolved as the static wild dynamic path is presented, Elysia will resolve the static path rather than the dynamic path
255255

@@ -276,7 +276,7 @@ new Elysia()
276276
}"
277277
/>
278278

279-
Sending a request to the server should return the response as the following:
279+
Here the server will respond as follows:
280280

281281
| Path | Response |
282282
| ------- | ------------- |

0 commit comments

Comments
 (0)