Skip to content

Commit 8a3cd5f

Browse files
committed
Fix docs
1 parent 83d9e5a commit 8a3cd5f

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

docs/guide/web/auth.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ JSON Web Tokens (JWT) provide a stateless authentication mechanism that's perfec
2222
```js
2323
post /signin {
2424
body {
25-
username: str
26-
password: str
25+
username: str,
26+
password: str,
2727
}
2828

2929
// Verify username and password correctly

docs/guide/web/validator.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ AIScript provides a simple way to validate request components using directives.
1414
get /hello {
1515
query {
1616
@string(min_len=3, max_len=10)
17-
name: str
18-
17+
name: str,
1918
@in(["male", "female"])
2019
gender: str
2120
}
@@ -29,8 +28,7 @@ post /hello {
2928
@json // or use @form to validate form data
3029
body {
3130
@regex(r"^\d{4}-\d{2}-\d{2}$")
32-
birthdate: str
33-
31+
birthdate: str,
3432
@format(type="email")
3533
email: str
3634
}

docs/reference/directives/route.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ post /api/users {
1111
@json
1212
body {
1313
name: str,
14-
email: str
14+
email: str,
1515
}
1616

1717
// Process body as JSON
18-
return "Created user: " + body.name;
18+
return f"Created user: {body.name}";
1919
}
2020
```
2121

@@ -28,11 +28,11 @@ post /api/contact {
2828
@form
2929
body {
3030
name: str,
31-
message: str
31+
message: str,
3232
}
3333

3434
// Process body as form data
35-
return "Received message from: " + body.name;
35+
return f"Received message from: {body.name}";
3636
}
3737
```
3838

@@ -74,7 +74,7 @@ Enables Single Sign-On authentication for the route.
7474
@sso(provider="google")
7575
get /dashboard {
7676
// User must be authenticated via Google SSO
77-
return "Welcome, " + user.name;
77+
return f"Welcome, {user.name}";
7878
}
7979
```
8080

docs/reference/route/keyword.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The `post` keyword defines a route handler for HTTP POST requests, which are typ
1919
```rust
2020
post /products {
2121
body {
22-
name: str
23-
price: float
24-
category: str
22+
name: str,
23+
price: float,
24+
category: str,
2525
}
2626

2727
// Validate input
@@ -104,8 +104,8 @@ route /user {
104104
}
105105

106106
body {
107-
name: str
108-
email: str
107+
name: str,
108+
email: str,
109109
}
110110

111111
// Update user with the given ID
@@ -122,8 +122,8 @@ Provides access to query parameters in the URL.
122122
```rust
123123
get /search {
124124
query {
125-
term: str
126-
page: int = 1
125+
term: str,
126+
page: int = 1,
127127
}
128128

129129
let term = query.term;
@@ -139,8 +139,8 @@ Contains route parameters defined with `:` in the route path.
139139
```rust
140140
get /users/:id/posts/:postId {
141141
path {
142-
id: str
143-
postId: int
142+
id: str,
143+
postId: int,
144144
}
145145

146146
let userId = path.id;
@@ -156,8 +156,8 @@ Contains the parsed request body. Automatically parsed based on Content-Type.
156156
```rust
157157
post /users {
158158
body {
159-
name: str
160-
email: str
159+
name: str,
160+
email: str,
161161
}
162162

163163
let name = body.name;

docs/reference/route/request.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Returns the HTTP method of the request (GET, POST, PUT, DELETE, etc.)
88

99
```rust
1010
get /echo {
11-
return "Method: " + request.method; // Returns "Method: GET"
11+
return f"Method: {request.method}"; // Returns "Method: GET"
1212
}
1313
```
1414

@@ -18,7 +18,7 @@ Returns the complete URL of the request.
1818

1919
```rust
2020
get /info {
21-
return "URL: " + request.url; // Might return "URL: https://example.com/info?key=value"
21+
return f"URL: {request.url}"; // Might return "URL: https://example.com/info?key=value"
2222
}
2323
```
2424

@@ -28,7 +28,7 @@ Returns the path portion of the URL.
2828

2929
```rust
3030
get /path/info {
31-
return "Path: " + request.path; // Returns "Path: /path/info"
31+
return f"Path: {request.path}"; // Returns "Path: /path/info"
3232
}
3333
```
3434

@@ -38,7 +38,7 @@ Returns the scheme of the request (http or https).
3838

3939
```rust
4040
get /scheme {
41-
return "Scheme: " + request.scheme; // Returns "Scheme: https" for secure requests
41+
return f"Scheme: {request.scheme}"; // Returns "Scheme: https" for secure requests
4242
}
4343
```
4444

@@ -48,7 +48,7 @@ Returns the host from the request.
4848

4949
```rust
5050
get /host {
51-
return "Host: " + request.host; // Might return "Host: example.com"
51+
return f"Host: {request.host}"; // Might return "Host: example.com"
5252
}
5353
```
5454

@@ -58,6 +58,6 @@ Returns the port number of the request.
5858

5959
```rust
6060
get /port {
61-
return "Port: " + request.port; // Might return "Port: 443" for HTTPS
61+
return f"Port: {request.port}"; // Might return "Port: 443" for HTTPS
6262
}
6363
```

0 commit comments

Comments
 (0)