Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_rest
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_rest
Commits
beba6af8
Commit
beba6af8
authored
7 years ago
by
Markus Guenther
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Remove the url scheme marker and use HTTS only
parent
7e220b3f
No related branches found
Branches containing commit
Tags
1.6.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Utility/PathUtility.php
+4
-5
4 additions, 5 deletions
Classes/Utility/PathUtility.php
README.md
+4
-4
4 additions, 4 deletions
README.md
with
8 additions
and
9 deletions
Classes/Utility/PathUtility.php
+
4
−
5
View file @
beba6af8
...
...
@@ -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
);
}
}
This diff is collapsed.
Click to expand it.
README.md
+
4
−
4
View file @
beba6af8
...
...
@@ -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 con
t
ain 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}}'
);
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment