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

The AbstractRequestHandler class defines an abstract base for sending HTTP-like requests. More...

#include <abstractrequesthandler.h>

Inherited by RestLink::NetworkManager, and RestLink::Server.

Public Types

enum  Method {
  HeadMethod , GetMethod , PostMethod , PutMethod ,
  PatchMethod , DeleteMethod , UnknownMethod = -1
}
 Defines supported HTTP methods for handling outgoing requests. More...
 
enum  HandlerType { NetworkManager , ServerHandler , UnknownHandler = -1 }
 Describes the type of request handler being used. More...
 

Public Member Functions

virtual ~AbstractRequestHandler ()
 Destructor for RequestHandler.
 
virtual QString handlerName () const
 Returns the name of the handler based on its type.
 
Responsehead (const Request &request)
 Sends a HEAD request.
 
Responseget (const Request &request)
 Sends a GET request.
 
Responsepost (const Request &request, const Body &body)
 Sends a POST request.
 
Responseput (const Request &request, const Body &body)
 Sends a PUT request.
 
Responsepatch (const Request &request, const Body &body)
 Sends a PATCH request.
 
ResponsedeleteResource (const Request &request)
 Sends a DELETE request.
 
Responsesend (Method method, const Request &request, const Body &body)
 
QList< AbstractRequestInterceptor * > requestInterceptors () const
 Returns the list of registered request interceptors.
 
void addRequestInterceptor (AbstractRequestInterceptor *interceptor)
 Adds a new request interceptor.
 
void removeRequestInterceptor (AbstractRequestInterceptor *interceptor)
 Removes a request interceptor.
 
virtual QStringList supportedSchemes () const =0
 
virtual HandlerType handlerType () const =0
 

Protected Member Functions

 AbstractRequestHandler ()
 
bool isRequestSupported (const Request &request) const
 Checks if the request is supported by this handler.
 
void initResponse (Response *response, const Request &request, Method method)
 Initializes the response object with the associated request.
 
virtual ResponsesendRequest (Method method, const Request &request, const Body &body)=0
 

Protected Attributes

QScopedPointer< AbstractRequestHandlerPrivate > d_ptr
 

Detailed Description

The AbstractRequestHandler class defines an abstract base for sending HTTP-like requests.

It provides generic methods to send requests using standard HTTP methods (GET, POST, etc.). Subclasses must implement scheme support and request sending behavior.

See also
NetworkManager

Member Enumeration Documentation

◆ Method

Defines supported HTTP methods for handling outgoing requests.

This enum is used to identify the HTTP method associated with a request.

Enumerator
HeadMethod 

Represents the HTTP HEAD method, used to retrieve headers without the response body.

GetMethod 

Represents the HTTP GET method, used to retrieve data from the server.

PostMethod 

Represents the HTTP POST method, used to submit data to the server.

PutMethod 

Represents the HTTP PUT method, used to update or replace existing resources.

PatchMethod 

Represents the HTTP PATCH method, used to apply partial modifications to a resource.

DeleteMethod 

Represents the HTTP DELETE method, used to remove a resource.

UnknownMethod 

Represents an unknown or unsupported HTTP method.

◆ HandlerType

Describes the type of request handler being used.

This enum helps identify the underlying implementation responsible for processing the request.

Enumerator
NetworkManager 

Indicates that the handler is based on the NetworkManager class (typically used for client-side requests).

ServerHandler 

Indicates that the handler is based on the Server class (typically used for server-side processing).

UnknownHandler 

Indicates an unknown or custom handler type not explicitly defined by the framework.

Constructor & Destructor Documentation

◆ ~AbstractRequestHandler()

RestLink::AbstractRequestHandler::~AbstractRequestHandler ( )
virtual

Destructor for RequestHandler.

◆ AbstractRequestHandler()

RestLink::AbstractRequestHandler::AbstractRequestHandler ( )
protected

Member Function Documentation

◆ handlerName()

QString RestLink::AbstractRequestHandler::handlerName ( ) const
virtual

Returns the name of the handler based on its type.

Note
this method can be overriden on subclasses.

◆ head()

Response * RestLink::AbstractRequestHandler::head ( const Request request)

Sends a HEAD request.

◆ get()

Response * RestLink::AbstractRequestHandler::get ( const Request request)

Sends a GET request.

◆ post()

Response * RestLink::AbstractRequestHandler::post ( const Request request,
const Body body 
)

Sends a POST request.

◆ put()

Response * RestLink::AbstractRequestHandler::put ( const Request request,
const Body body 
)

Sends a PUT request.

◆ patch()

Response * RestLink::AbstractRequestHandler::patch ( const Request request,
const Body body 
)

Sends a PATCH request.

◆ deleteResource()

Response * RestLink::AbstractRequestHandler::deleteResource ( const Request request)

Sends a DELETE request.

◆ send()

Response * RestLink::AbstractRequestHandler::send ( Method  method,
const Request request,
const Body body 
)

◆ requestInterceptors()

QList< AbstractRequestInterceptor * > RestLink::AbstractRequestHandler::requestInterceptors ( ) const

Returns the list of registered request interceptors.

◆ addRequestInterceptor()

void RestLink::AbstractRequestHandler::addRequestInterceptor ( AbstractRequestInterceptor interceptor)

Adds a new request interceptor.

◆ removeRequestInterceptor()

void RestLink::AbstractRequestHandler::removeRequestInterceptor ( AbstractRequestInterceptor interceptor)

Removes a request interceptor.

◆ supportedSchemes()

virtual QStringList RestLink::AbstractRequestHandler::supportedSchemes ( ) const
pure virtual

Implemented in RestLink::NetworkManager.

◆ handlerType()

virtual HandlerType RestLink::AbstractRequestHandler::handlerType ( ) const
pure virtual

◆ isRequestSupported()

bool RestLink::AbstractRequestHandler::isRequestSupported ( const Request request) const
protected

Checks if the request is supported by this handler.

◆ initResponse()

void RestLink::AbstractRequestHandler::initResponse ( Response response,
const Request request,
Method  method 
)
protected

Initializes the response object with the associated request.

It's recommended to use this method to initialize your response objects.

◆ sendRequest()

virtual Response * RestLink::AbstractRequestHandler::sendRequest ( Method  method,
const Request request,
const Body body 
)
protectedpure virtual

Member Data Documentation

◆ d_ptr

QScopedPointer<AbstractRequestHandlerPrivate> RestLink::AbstractRequestHandler::d_ptr
protected