Table of Contents
- ๐ฆ Class iml\tinyapi
- ๐ถ Properties
-
๐ท Methods
- ๐น public __construct()
- ๐น public allowIPs()
- ๐น public allowMethods()
- ๐น public allowUsers()
- ๐น public appendData()
- ๐น public checkIp()
- ๐น public checkMethod()
- ๐น public checkUser()
- ๐น public sendError()
- ๐น public sendJson()
- ๐น public setData()
- ๐น public setPretty()
- ๐น public stopIfOptions()
๐ฆ Class iml\tinyapi
๐ถ Properties
(none)
๐ท Methods
๐น public __construct()
constructor
Return: ``
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> array $aRequirements = [] | array |
optional: requirements with subkeys methods ips |
๐น public allowIPs()
Set allowed ip addresses by a given list of regex
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> array $aIpRegex | array |
array aIpRegex array of regex |
๐น public allowMethods()
Set allowed http methods
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> array $aMethods | array |
array aMethods array of strings containing GET, PUT, POST, DELETE, OPTIONS |
๐น public allowUsers()
Set allowed users
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> array $aUsers | array |
array aUsers array of allowed users; key= username (โโ or userid); subkeys: - โpasswordโ; value = password hash (BASIC AUTH) and/ or - โsecretโ; clear text for hmac |
๐น public appendData()
Append response dataIf no key as 2nd param is given the given array will be added as new array element.With a given key the key will be used to set data (existing key will be replaced)
Return: bool
Parameters: 2
Parameter | Type | Description |
---|---|---|
<required> mixed $aData | mixed |
additional response data |
<optional> string $sKey = โโ | string |
optional: use key |
๐น public checkIp()
Check allowed ip addresses by a given list of regex.It aborts if no ip address was detected.If access is not allowed it sends a 401 header and aborts.
Return: bool
Parameters: 0
๐น public checkMethod()
Check allowed http methods
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> array $aMethods = [] | array |
array aMethods optional: array of strings containing GET, PUT, POST, DELETE, OPTIONS |
๐น public checkUser()
Get an authenticated user and return a detected username as string.Checks are done in that sequence- sent basic auth (base64 encoded
Return: string
Parameters: 0
๐น public sendError()
Send error message using the sendJson method.
Return: void
Parameters: 2
Parameter | Type | Description |
---|---|---|
<required> int $iHttpstatus | int |
http statuscode |
<required> string $sErrormessage | string |
string with error message |
๐น public sendJson()
Send API response:set content type in http response header and transform data to jsonand stop.
Return: void
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> array $aData = [] | array |
array of data to send |
๐น public setData()
Set response data; โshouldโ be an array
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> array $aData | array |
response data |
๐น public setPretty()
Set response data; โshouldโ be an array
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> bool $bPretty | bool |
response data |
๐น public stopIfOptions()
If http method is OPTIONS, send json and stop.
Return: void
Parameters: 0
Generated with Axels PHP class doc parser.