Become a member!

DMVCFramework 3.4.0-neon - What's New

DMVCFramework 3.4.0-neon

Release Date: September 7, 2023

This is a landmark release introducing Functional Actions, Named Queries, and HTMX integration.


Major New Features

Functional Actions with IMVCResponse

Return data directly from controller methods with proper HTTP semantics:

function TCustomerController.GetCustomer(const ID: Integer): IMVCResponse;
begin
  Result := OKResponse(FRepository.GetByPK(ID));
end;

function TCustomerController.CreateCustomer(
  [MVCFromBody] const Customer: TCustomer): IMVCResponse;
begin
  FRepository.Insert(Customer);
  Result := CreatedResponse('/api/customers/' + Customer.ID.ToString);
end;

function TCustomerController.DeleteCustomer(const ID: Integer): IMVCResponse;
begin
  FRepository.DeleteByPK(ID);
  Result := NoContentResponse;
end;

Response Helpers:

  • OKResponse(Data) - HTTP 200
  • CreatedResponse(Location) - HTTP 201
  • NoContentResponse - HTTP 204
  • BadRequestResponse(Message) - HTTP 400
  • NotFoundResponse - HTTP 404

Named Queries

Define reusable queries with attributes:

[MVCTable('customers')]
[MVCNamedSQLQuery('GetActiveCustomers', 'SELECT * FROM customers WHERE active = 1')]
[MVCNamedSQLQuery('GetByCountry', 'SELECT * FROM customers WHERE country = ?')]
[MVCNamedRQLQuery('GetRecent', 'sort(-created_at);limit(10)')]
TCustomer = class(TMVCActiveRecord)
  // ...
end;

// Usage
Customers := TMVCActiveRecord.SelectByNamedQuery<TCustomer>('GetActiveCustomers', []);

HTMX Integration

Build dynamic web applications with minimal JavaScript:

// Check if request is from HTMX
if Context.Request.IsHTMX then
begin
  // Return partial HTML
  Render(PartialView);
end;

// HTMX response headers
Context.Response.HXTrigger('customerUpdated');
Context.Response.HXRedirect('/customers');

New Samples:

  • htmx - Basic HTMX integration
  • htmx_website_with_templatepro - Full website with HTMX + TemplatePro

MVCResponseBuilder

Fluent API for building responses:

Result := MVCResponseBuilder
  .StatusCode(HTTP_STATUS.OK)
  .Body(Customer)
  .Header('X-Custom', 'Value')
  .Build;

Other Improvements

Server-Side Sessions

  • File-based session persistence
  • Improved session handling

CORS Middleware

  • Improved CORS configuration
  • Better preflight handling

Bug Fixes

  • Fixed data decompression in TMVCRestClient on macOS/iOS
  • Fixed JWT default initialization
  • Improved TMVCResponse rendering


← Back to DMVCFramework

Comments

comments powered by Disqus