Sign in Join
FPDoc Onlineexperiment

HTTPRoute unit

HTTP request routing implementation

The HttpRoute unit provides HTTP request routing functionality for web applications. It defines the THTTPRouter class, which allows mapping URL patterns to specific handlers based on HTTP methods and path patterns, with support for callbacks, events, objects, and interfaces as route handlers.

A global instance of the router is available in HTTPRouter, this is where you must register your routes: the rest of the FPC web framework uses this global instance to determine where to route requests to.

Classes and records

EHTTPRouteclassHTTP routing exception class
IRouteInterfaceinterfaceInterface for route request handlers
THTTPRouteclassBase HTTP route class
THTTPRouteCallbackclassRoute with callback procedure handler
THTTPRouteCallbackExclassRoute with extended callback handler
THTTPRouteEventclassRoute with object event handler
THTTPRouteInterfaceclassRoute with interface-based handler
THTTPRouteListclassCollection of HTTP routes
THTTPRouteObjectclassRoute with object class handler
THTTPRouterclassHTTP request router class
TRequestInterceptorItemclassSingle request interceptor definition
TRequestInterceptorListclassCollection of request interceptors
TRouteObjectclassBase class for route handler objects

Procedures and functions

HTTPRouterfunctionReturns the global HTTP router instance
RouteMethodToStringfunctionConverts route method enumeration to string

Types

THTTPRouteClasstypeClass reference type for HTTP route
THTTPRouterClasstypeClass reference type for HTTP router
THTTPRouteRequestEventprocedure typeEvent type for HTTP route requests
TInterceptAtenumerationTiming enumeration for request interception
TRequestInterceptEventprocedure typeEvent type for request interception
TRouteCallBackprocedure typeProcedure type for route callback handlers
TRouteCallBackExprocedure typeExtended callback procedure type with user data
TRouteEventprocedure typeEvent type for route handlers
TRouteMethodenumerationHTTP method enumeration for routing
TRouteObjectClasstypeClass reference type for route objects
TRouteOptionenumerationRoute matching options enumeration
TRouteOptionssetSet of route matching options

Constants

RouteMethodNamesconstantArray constant containing HTTP method name strings

Topics

HttpRouterAdvancedHandlerstopicAdvanced HTTP Router Handler Examples
HttpRouterBasicUsagetopicBasic HTTP Router Usage
HttpRouterHandlerTypestopicHTTP Router Handler Types
HttpRouterInterceptorstopicHTTP Router Interceptors and Middleware
HttpRouterMethodstopicHTTP Router Methods and RESTful APIs
HttpRouterParameterstopicHTTP Router Parameterized Routes
HttpRouterPrincipletopicHTTP Router Working Principle

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.