Skip to content
Snippets Groups Projects
Commit beba6af8 authored by Markus Guenther's avatar Markus Guenther
Browse files

[TASK] Remove the url scheme marker and use HTTS only

parent 7e220b3f
No related branches found
Tags 1.6.0
No related merge requests found
......@@ -240,8 +240,8 @@ class PathUtility {
* If you have some url redirects the REST base URI is maybe different and need url segments between the host and
* the apikey. You are able to adjust the base URI with the url pattern parameter.
*
* The url pattern should contain the marker HOST, APIKEY, ENTITY, SCHEME. The markers use handlebars. So a pattern
* looks like: {{SCHEME}}{{HOST}}/{{APIKEY}}/{{ENTITY}}
* The url pattern should contain the marker HOST, APIKEY, ENTITY. The markers use handlebars. So a pattern
* looks like: {{HOST}}/{{APIKEY}}/{{ENTITY}}
*
* @param string $apiKey
* @param string $entity
......@@ -253,9 +253,8 @@ class PathUtility {
/** @var RegistrationService $registrationService */
$registrationService = GeneralUtility::makeInstance('SGalinski\SgRest\Service\RegistrationService');
$accessGroup = $registrationService->getAccessGroupByApiKey($apiKey);
$defaultUrlPattern = '{{SCHEME}}{{HOST}}/{{APIKEY}}/{{ENTITY}}';
$defaultUrlPattern = '{{HOST}}/{{APIKEY}}/{{ENTITY}}';
$urlSegments = [
'{{SCHEME}}' => GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://',
'{{HOST}}' => GeneralUtility::getIndpEnv('HTTP_HOST'),
'{{ENTITY}}' => GeneralUtility::camelCaseToLowerCaseUnderscored($entity),
'{{APIKEY}}' => $apiKey
......@@ -267,6 +266,6 @@ class PathUtility {
}
$urlPattern = trim($urlPattern) === '' ? $defaultUrlPattern : $urlPattern;
return str_replace(array_keys($urlSegments), array_values($urlSegments), $urlPattern);
return 'https://' . str_replace(array_keys($urlSegments), array_values($urlSegments), $urlPattern);
}
}
......@@ -220,17 +220,17 @@ RewriteRule ^(.+)$ index.php?eID=sgRestApi&request=%{REQUEST_URI} [QSA,NC,L]
## Customize the REST url pattern
If your REST url is not a subdomain you maybe have a url segment after the host or something completely different.
The default url pattern is like SCHEME/HOST/APIKEY/ENTITY and if your host does not conain the identifier for your API,
The default url pattern is like HOST/APIKEY/ENTITY and if your host does not contain the identifier for your API,
you need to adjust the REST url pattern. Otherwise your pagination service will generate invalid next and previous URLs.
You don't need to add a url scheme. HTTPS is required and will be always used.
The url pattern uses handlebars for the markers. The following markers exist:
* {{HOST}}
* {{APIKEY}}
* {{ENTITY}}
* {{SCHEME}}
So the default pattern is: ```{{SCHEME}}{{HOST}}/{{APIKEY}}/{{ENTITY}}```
So the default pattern is: ```{{HOST}}/{{APIKEY}}/{{ENTITY}}```
If you want to adjust the URL from https://api.yourdomain.com/apikey/entity to
https://www.yourdomain.com/api/apikey/entity for instance. You just need to set a new url pattern to the
......@@ -241,5 +241,5 @@ pagination service.
$paginationService = $this->objectManager->get(
PaginationService::class, $page, $limit, 10, $amountOfEntries, $apiKey
);
$paginationService->setUrlPattern('{{SCHEME}}{{HOST}}/api/{{APIKEY}}/{{ENTITY}}');
$paginationService->setUrlPattern('{{HOST}}/api/{{APIKEY}}/{{ENTITY}}');
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment