Comments (23)
I thought about releasing v4, but then your error report came in :)
from rest.
Thanks, I use a Composer approach. Will give it a try and report results here.
from rest.
Thank you for reporting.
Do you have a link to the deprecation in the TYPO3 docs?
from rest.
Can't find corresponding deprecation note, but the diff is there: https://github.com/TYPO3/TYPO3.CMS/blob/v9.5.0/typo3/sysext/core/Classes/Http/Dispatcher.php#L38
T3 9.4 had completely different approach serving requests (using eID) through Dispatchar, than T3 9.5.
Looks like, in 9.5 You need to init own Response object in \Cundd\Rest\BootstrapDispatcher or in \Cundd\Rest\Dispatcher object
from rest.
I think I found the deprecation note. Unfortunately it only mentions Backend controllers in its title.
from rest.
The bug should be fixed in version 4 (commit 064a641). Would be great if you could test it.
from rest.
Sure, I will test, but please help me do this, as I don't know how to install dev branch version.
When are You going to deploy stable v4?
from rest.
The easiest way is to checkout the v4 branch from github. Or require as "cundd/rest": "dev-v4"
in your composer.json. How is your TYPO3 installation deployed?
from rest.
Installed via Composer: v4.x-dev. It works fine! Thanks.
@cundd I started building React-Admin
app, had succesfully configured REST ext, got connected from RA to REST, using React-Admin-Simple-Rest-Dataprovider
, but it requires to receive a Content-Range
header with total number of items in a list. I'd like to add support for this header to Your REST ext, so I also need to know, if extending Your ext without overwriting core files is possible. How can I achieve such solution?
from rest.
That's great!
I just made a change to the Dispatcher (30e4092)
You can specify a userFunc
in the TypoScript configuration for additional response headers. Now the response will be passed in the parameters array sent to the custom userFunc. You can try to grab the response from there and count the entries.
The other solution is to create a custom Handler for your requests.
from rest.
Thank You for all Your effort and quick fixes.
from rest.
I am familiar with using userFunc
, also I just found a way to get content from Response
object
$response->getBody()->rewind(); $newResponse->getBody()->getContents();
but still it is a mystery to me, where to attach userFunc
in TypoScript configuration: is it plugin.tx_rest.settings.responseHeaders.userFunc
?
from rest.
The following should work.
But I have to give in I never used it...
plugin.tx_rest.settings {
responseHeaders {
Content-Range {
userFunc = xyz
}
}
}
from rest.
It's clear now. Thanks. Will post back to confirm this method.
Getting response content again is not a perfect way counting elements, do You think it is possible and purposefull to set a number of items during listAll proceess? It would be useful to not process the result two times.
from rest.
Yes it's not optimal.
Is the Content-Range
header as it is used by React-Admin-Simple-Rest-Dataprovider
a "standard" header?
from rest.
It is only required for GET_LIST requests
Note: The simple REST data provider expects the API to include a Content-Range header in the response to GET_LIST calls. The value must be the total number of resources in the collection. This allows react-admin to know how many pages of resources there are in total, and build the pagination controls.
from rest.
I meant more if it is a standard HTTP header and if the format "posts 0-24/319" is common.
It looks like the header depends on a lot of other stuff:
- Needs to have a way to get the correct noun ("posts" in the example)
- Requires additional CORS headers
- Maybe needs an additional request header (
Accept-Ranges
)
In contrast to the PSR7 ServerRequestInterface
the ResponseInterface
does not support attributes (https://www.php-fig.org/psr/psr-7/) which would have been handy to attach the total number of results to the response.
So unfortunately I don't see an easy general implementation possibility for the REST extension. Or do you have a good idea?
from rest.
I used Content-Range
while streaming videos to html5 player, but it looks like this header is not narrowed to bytes
units. see Mozilla docs here
I will dig through the code of ra-data-simple-rest
to find out what are its requirements about those noun names ie. 'posts' and if it needs to receive those names in API response.
Maybe a little tweak is required to ra-data-simple-rest
to change its behaviour not checking Headers but instead try to implement CountAll method. By the way, is _count/?
a standard in REST?
from rest.
_count/
: No I don't think so 😉
from rest.
It was discussed also on StackOverflow
Read here
from rest.
Thank's for the link.
I decided to go with /_count
, because I didn't want to implement pagination and I also wanted to be able to send a request that only counts the results without really loading them from the DB (because of performance).
I chose _count
as keyword because it should most likely not collision with an identifier/UID.
from rest.
Looks like I need to do my own mods to ra-data-simple-rest
or use different data provider. Thanks anyway for Your time.
from rest.
No problem!
from rest.
Related Issues (20)
- Allow cacheLifeTime to be overwritten for given path level HOT 3
- typo3scan against TYPO3 9 HOT 6
- is querying for values possible? HOT 2
- Additional Header missing if isUnauthorized or isDenied HOT 2
- Documentation Page is not available HOT 2
- Allow URL encoded strings in {slug} or add sub-regex expression support
- composer require Error HOT 2
- Typo3 Site Handling not supported? HOT 5
- Implement PSR-15 middleware HOT 1
- Adapt definition of fe_user.tx_rest_apikey HOT 1
- how to get content of languages ? HOT 2
- Compatibility with TYPO3 v10 HOT 4
- Cannot instantiate ObjectManagerInterface HOT 4
- Version development HOT 6
- Typo3 version 11 support HOT 3
- Wrong ConfigurationManager initialized in TYPO3 v11 HOT 3
- V6 and PHP 8.2 compatibility HOT 4
- Feature request: Allow to disable cache for route HOT 3
- Exception when applying the default configuration. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest.