ApiController
extends KBase
in package
API Controller base class for handling API requests.
Tags
Table of Contents
- $cfg : object
- Config class instance.
- $request : Request
- Server request class instance.
- index() : mixed
- API Controller index action.
- validateMethod() : bool
- Validate the HTTP method.
- validateSign() : bool
- Validate the sign.
- validateToken() : bool
- Validate the API token.
- validateTokenBearer() : bool
- Validate the Bearer token.
Properties
$cfg
Config class instance.
protected
static object
$cfg
$request
Server request class instance.
protected
static Request
$request
Methods
index()
API Controller index action.
public
index(Request $request) : mixed
Parameters
- $request : Request
-
The HTTP request object.
Return values
mixed —validateMethod()
Validate the HTTP method.
public
static validateMethod(Request $request, string $method) : bool
Parameters
- $request : Request
-
The HTTP request object.
- $method : string
-
The expected HTTP method (e.g., POST, GET, PUT, DELETE, OPTIONS).
Return values
bool —True if the method is valid, otherwise throws an ApiException with a "Method not allowed" error.
validateSign()
Validate the sign.
public
static validateSign(array<string|int, mixed> $params) : bool
Parameters
- $params : array<string|int, mixed>
-
The parameters to validate.
Return values
bool —True if the sign is valid, otherwise throws an ApiException with an "Invalid sign" error.
validateToken()
Validate the API token.
public
static validateToken(string $token) : bool
Parameters
- $token : string
-
The token to validate.
Return values
bool —True if the token is valid, otherwise throws an ApiException with an "Invalid token" error.
validateTokenBearer()
Validate the Bearer token.
public
static validateTokenBearer(Request $request) : bool
Parameters
- $request : Request
-
The HTTP request object.
Return values
bool —True if the token is valid, otherwise throws an ApiException with an "Invalid token" error.