1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vweb: host attribute (#18288)

This commit is contained in:
Lenni0451
2023-05-29 02:11:10 +02:00
committed by GitHub
parent f22ba836fd
commit 2904c399b5
3 changed files with 95 additions and 60 deletions

View File

@ -251,6 +251,24 @@ pub fn (mut app App) controller_get_user_by_id() vweb.Result {
return app.text(app.query.str())
}
```
#### - Host
To restrict an endpoint to a specific host, you can use the `host` attribute
followed by a colon `:` and the host name.
**Example:**
```v ignore
['/'; host: 'example.com']
pub fn (mut app App) hello_web() vweb.Result {
return app.text('Hello World')
}
['/'; host: 'api.example.org']
pub fn (mut app App) hello_api() vweb.Result {
return app.text('Hello API')
}
```
### Middleware
Vweb has different kinds of middleware.