-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
A WiRL application is basically an HTTP server with a routing system that follow the ReST specification. The core of the application is the Engine that handle all the HTTP requests and send each one to the right sub-module called Application. Each application has its own resources and filters used to process the requests.
The following example shows a basic configuration:
begin
// Create http server
FServer := TWiRLhttpServerIndy.Create;
// Engine configuration
FServer.ConfigureEngine('/rest')
.SetPort(8080)
.SetName('WiRL Demo')
.SetThreadPoolSize(5)
// Application configuration
.AddApplication('/app')
.SetName('Default App')
.SetResources('*')
.SetFilters('*')
;
FServer.Active := True;
end;This configuration define an application that answers to URLs like this:
http://localhost:8080/rest/app/<resource_path>
The WiRL engine can handle many sub-applications, each application can have different resources, filters and authentication systems but they can also be shared.
Let's try with an examples:
begin
// ...
// First application
FEngine.AddApplication('/auth')
.SetName('Autentication Module')
.SetResources('Server.Auth.TAuthResource,Server.Audit.TMonitorResource')
;
// Second application
FEngine.AddApplication('/order')
.SetName('Order Module')
.SetResources([
'Server.Order.TOrderResource',
'Server.Order.TCustomerResource',
'Server.Audit.TMonitorResource'])
;
// ...
end;In this example we configure two applications, the first handle two resources: TAuthResource and TMonitorResource the second three resources: TOrderResource, TCustomerResource and TMonitorResource. As you can see the TMonitorResource is used by both applications. You can notice that the SetResources method has two different syntax, the first is for compatibility with the older version of Delphi.
The TWiRLApplication class has some configuration options used during the authentication process. These are:
- Secret: the secret key of the JWT token
- AuthChallengeHeader: the HTTP header used during the authentication challenge
- TokenLocation: the JWT token location (Bearer, Cookie, Header)
- TokenCustomHeader: if the JWT is in a custom header you can specify which one
- ClaimClass: the class that has all the custom JWT claims
If you need more information about standard WiRL authentication you can read the Authentication and Authorization page.