mirror of
https://github.com/flextype/flextype.git
synced 2025-08-07 21:56:33 +02:00
feat(endpoints): simple updates for images, media and registry rest api
This commit is contained in:
@@ -38,14 +38,14 @@ function validate_images_token(string $token): bool
|
||||
* Returns:
|
||||
* Image file
|
||||
*/
|
||||
flextype()->get('/api/images/{path:.+}', function (Request $request, Response $response, $args) use ($api_errors) {
|
||||
flextype()->get('/api/images/{path:.+}', function (Request $request, Response $response, $args) use ($apiErrors) {
|
||||
// Get Query Params
|
||||
$query = $request->getQueryParams();
|
||||
|
||||
if (! isset($query['token'])) {
|
||||
return $response->withStatus($api_errors['0400']['http_status_code'])
|
||||
return $response->withStatus($apiErrors['0400']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0400']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0400']));
|
||||
}
|
||||
|
||||
// Set variables
|
||||
@@ -62,9 +62,9 @@ flextype()->get('/api/images/{path:.+}', function (Request $request, Response $r
|
||||
$delivery_images_token_file_data['state'] === 'disabled' ||
|
||||
($delivery_images_token_file_data['limit_calls'] !== 0 && $delivery_images_token_file_data['calls'] >= $delivery_images_token_file_data['limit_calls'])
|
||||
) {
|
||||
return $response->withStatus($api_errors['0003']['http_status_code'])
|
||||
return $response->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
}
|
||||
|
||||
// Update calls counter
|
||||
@@ -75,25 +75,25 @@ flextype()->get('/api/images/{path:.+}', function (Request $request, Response $r
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0402']['http_status_code'])
|
||||
->withStatus($apiErrors['0402']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0402']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0402']));
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0003']['http_status_code'])
|
||||
->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0003']['http_status_code'])
|
||||
->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0003']['http_status_code'])
|
||||
->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -36,14 +36,14 @@ function validate_registry_token(string $token): bool
|
||||
* Returns:
|
||||
* An array of registry item objects.
|
||||
*/
|
||||
flextype()->get('/api/registry', function (Request $request, Response $response) use ($api_errors) {
|
||||
flextype()->get('/api/registry', function (Request $request, Response $response) use ($apiErrors) {
|
||||
// Get Query Params
|
||||
$query = $request->getQueryParams();
|
||||
|
||||
if (! isset($query['id']) || ! isset($query['token'])) {
|
||||
return $response->withStatus($api_errors['0300']['http_status_code'])
|
||||
return $response->withStatus($apiErrors['0300']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0300']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0300']));
|
||||
}
|
||||
|
||||
// Set variables
|
||||
@@ -61,9 +61,9 @@ flextype()->get('/api/registry', function (Request $request, Response $response)
|
||||
$registry_token_file_data['state'] === 'disabled' ||
|
||||
($registry_token_file_data['limit_calls'] !== 0 && $registry_token_file_data['calls'] >= $registry_token_file_data['limit_calls'])
|
||||
) {
|
||||
return $response->withStatus($api_errors['0003']['http_status_code'])
|
||||
return $response->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
}
|
||||
|
||||
// Fetch registry
|
||||
@@ -85,9 +85,9 @@ flextype()->get('/api/registry', function (Request $request, Response $response)
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
return $response
|
||||
->withStatus($api_errors['0302']['http_status_code'])
|
||||
->withStatus($apiErrors['0302']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0302']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0302']));
|
||||
}
|
||||
|
||||
// Return response
|
||||
@@ -96,19 +96,19 @@ flextype()->get('/api/registry', function (Request $request, Response $response)
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0003']['http_status_code'])
|
||||
->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0003']['http_status_code'])
|
||||
->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
}
|
||||
|
||||
return $response
|
||||
->withStatus($api_errors['0003']['http_status_code'])
|
||||
->withStatus($apiErrors['0003']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('serializers')->json()->encode($api_errors['0003']));
|
||||
->write(flextype('serializers')->json()->encode($apiErrors['0003']));
|
||||
});
|
||||
|
Reference in New Issue
Block a user