-
Notifications
You must be signed in to change notification settings - Fork 0
VirtualHost Object
VirtualHost
new VirtualHost (host)
Name | Type | Description | ||
---|---|---|---|---|
host | text | ← | Host name | |
return | object | ← | VirtualHost object |
This method creates and returns a VirtualHost
object.
It can be used to diverge routes by named host.
This function just creates a VirtualHost
object on memory. So you must register it to the main application using HttpServer.use(VirtualHost)
function after you've finished to add routes to the VirtualHost
.
When the same path is registered to a VirtualHost and the HttpServer, the route belongs to the VirtualHost has priority.
C_OBJECT($app_o;$vhost_o)
$app_o:=new HttpServer
$app_o.get("/hoge";Formula(DefaultMethodName))
$vhost_o:=new VirtualHost("api.foo.com")
$vhost_o.get("/hoge";Formula(ApiMethodName))
$app_o.use($vhost_o)
In the above case, when the host name and the pass combination is:
- api.foo.com/hoge : ApiMethodName will be invoked
- any other host name and the pass "/hoge" : DefaultMethodName will be invoked
Nevertheless of the order of the route registration, routes that matches the virtual host name will be selected, if any.
The VirtualHost
object has the same routing functions with HttpServer
object.
For detail description on each function, please refer to HttpServer
page.
Functions provided with this object are:
VirtualHost.all()
VirtualHost.delete()
VirtualHost.get()
VirtualHost.method()
VirtualHost.post()
VirtualHost.put()
VirtualHost.route()
VirtualHost.use()