TXDataServer Class
Component that publishes an XData REST API server, creating and configuring a XData.Server.Module.TXDataServerModule from its design-time settings.
Remarks
Drop the component on a form or data module, set TSparkleServer.BaseUrl to the address the API should respond at, assign TSparkleServer.Dispatcher to a Sparkle dispatcher component and Pool to a connection pool component. When the dispatcher is activated, the server module is created and starts serving requests. Most properties map directly to a property with the same name in the created server module.
Syntax
Unit: XData.Comp.Server
TXDataServer = class(TXDataCustomServer);
Properties
| Name | Description |
|---|---|
| BaseUrl | Gets or sets the base URL the XData API responds at. |
| DefaultEntitySetPermissions | Gets or sets the permissions applied to all entity sets that are not listed in EntitySetPermissions. |
| DefaultExpandLevel | Gets or sets the minimum level up to which associated entities are expanded (included inline) in JSON responses. |
| Dispatcher | Gets or sets the dispatcher component that owns the HTTP server serving this API. |
| EnableEntityKeyAsSegment | Indicates whether single entities can also be addressed using the URL format /entityset/id, in addition to the default /entityset(id). |
| EntityLoopHandling | Gets or sets how circular references between entities are handled when writing JSON responses. |
| EntitySetPermissions | Gets or sets the collection of per-entity-set permissions, which override DefaultEntitySetPermissions for the entity sets listed in it. |
| FlushMode | Gets or sets whether the object manager flushes all pending changes or only the entity being processed, when saving changes requested by the client. |
| InstanceLoopHandling | Gets or sets how circular references between plain objects are handled when writing JSON responses. |
| ModelName | Gets or sets the name of the XData model used to build the API. |
| Pool | Gets or sets the connection pool component that provides the database connections used by the server. |
| PostMode | Gets or sets how the server applies a POST request to the database. |
| ProxyListLoadDepth | Gets or sets the maximum depth at which many-valued lazy associations are automatically loaded when building the response. |
| ProxyLoadDepth | Gets or sets the maximum depth at which single-valued lazy associations are automatically loaded when building the response. |
| PutMode | Gets or sets how the server applies a PUT request to the database. |
| RedocOptions | Gets or sets the options of the Redoc interface published by the server. |
| RoutingPrecedence | Gets or sets which endpoint wins when the URL of an automatic CRUD endpoint conflicts with the URL of a service operation. |
| SerializeInstanceRef | Gets or sets when an instance reference (the $ref token) is used in JSON responses for an object that appears more than once. |
| SerializeInstanceType | Gets or sets when the object type (the xdata.type annotation) is included in JSON responses. |
| SwaggerOptions | Gets or sets the options of the OpenAPI (Swagger) document published by the server. |
| SwaggerUIOptions | Gets or sets the options of the Swagger UI interface published by the server. |
| UnknownMemberHandling | Gets or sets how the server behaves when the JSON received from the client contains a property that is not known for that request. |
Events
| Name | Description |
|---|---|
| OnEntityDeleted | Occurs right after an entity is deleted from the database. |
| OnEntityDeleting | Occurs right before an entity is deleted from the database, in the middle of the database transaction. |
| OnEntityGet | Occurs after an entity is retrieved, right before it is sent to the client. |
| OnEntityInserted | Occurs right after an entity is inserted in the database. |
| OnEntityInserting | Occurs right before an entity is inserted in the database, in the middle of the database transaction. |
| OnEntityList | Occurs when the client queries an entity collection, after the criteria is built from the request and right before it is executed. |
| OnEntityModified | Occurs right after an entity is updated in the database. |
| OnEntityModifying | Occurs right before an entity is updated in the database, in the middle of the database transaction. |
| OnGetPoolInterface | Occurs when the server retrieves the connection pool interface, allowing a custom implementation to be provided. |
| OnManagerCreate | Occurs when an object manager is created to process a request, allowing it to be configured, for example to enable filters. |
| OnModuleCreate | Occurs after the XData server module is created, allowing further customization of the module before the server starts. |
| OnModuleException | Occurs when an exception is raised while processing a request, allowing the error response to be customized. |