RestLink 2.2.0
Powerfull Rest Client for Qt
Loading...
Searching...
No Matches
Public Member Functions | List of all members
RestLink::AbstractResourceController Class Referenceabstract

Provides a base interface for RESTful resource controllers. More...

#include <resourcecontroller.h>

Inherits RestLink::AbstractController.

Public Member Functions

virtual ~AbstractResourceController ()=default
 Virtual destructor for cleanup in derived classes.
 
virtual void index (const ServerRequest &request, ServerResponse *response)=0
 Handles the listing of resources.
 
virtual void show (const ServerRequest &request, ServerResponse *response)=0
 Handles showing a single resource.
 
virtual void update (const ServerRequest &request, ServerResponse *response)=0
 Handles updating a resource.
 
virtual void store (const ServerRequest &request, ServerResponse *response)=0
 Handles creating a new resource.
 
virtual void destroy (const ServerRequest &request, ServerResponse *response)=0
 Handles deleting a resource.
 
bool canProcessRequest (const ServerRequest &request) const override
 Checks whether the controller can process the given request.
 
void processRequest (const ServerRequest &request, ServerResponse *response) override
 Processes the incoming request and dispatches it to the appropriate handler method.
 

Detailed Description

Provides a base interface for RESTful resource controllers.

This abstract class defines standard CRUD operations (index, show, update, store, destroy) to be implemented by subclasses for handling requests in a RESTful manner. It also overrides request processing logic to dispatch requests to the appropriate method.

Constructor & Destructor Documentation

◆ ~AbstractResourceController()

RestLink::AbstractResourceController::~AbstractResourceController ( )
virtualdefault

Virtual destructor for cleanup in derived classes.

Member Function Documentation

◆ index()

void RestLink::AbstractResourceController::index ( const ServerRequest request,
ServerResponse response 
)
pure virtual

Handles the listing of resources.

This method should be implemented to respond to a GET request on a collection route.

◆ show()

void RestLink::AbstractResourceController::show ( const ServerRequest request,
ServerResponse response 
)
pure virtual

Handles showing a single resource.

This method should be implemented to respond to a GET request on a single item route.

◆ update()

void RestLink::AbstractResourceController::update ( const ServerRequest request,
ServerResponse response 
)
pure virtual

Handles updating a resource.

This method should be implemented to respond to a PUT or PATCH request on a single item route.

◆ store()

void RestLink::AbstractResourceController::store ( const ServerRequest request,
ServerResponse response 
)
pure virtual

Handles creating a new resource.

This method should be implemented to respond to a POST request on a collection route.

◆ destroy()

void RestLink::AbstractResourceController::destroy ( const ServerRequest request,
ServerResponse response 
)
pure virtual

Handles deleting a resource.

This method should be implemented to respond to a DELETE request on a single item route.

◆ canProcessRequest()

bool RestLink::AbstractResourceController::canProcessRequest ( const ServerRequest request) const
overridevirtual

Checks whether the controller can process the given request.

Typically used to determine if the controller supports the request method and route.

Reimplemented from RestLink::AbstractController.

◆ processRequest()

void RestLink::AbstractResourceController::processRequest ( const ServerRequest request,
ServerResponse response 
)
overridevirtual

Processes the incoming request and dispatches it to the appropriate handler method.

Dispatch logic typically maps request methods to controller actions like index, show, update, etc.

Implements RestLink::AbstractController.