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:
@ -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.
|
||||
|
Reference in New Issue
Block a user