Git Product home page Git Product logo

Comments (23)

cundd avatar cundd commented on August 23, 2024 1

I thought about releasing v4, but then your error report came in :)

from rest.

qbadev avatar qbadev commented on August 23, 2024 1

Thanks, I use a Composer approach. Will give it a try and report results here.

from rest.

cundd avatar cundd commented on August 23, 2024

Thank you for reporting.

Do you have a link to the deprecation in the TYPO3 docs?

from rest.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

I think I found the deprecation note. Unfortunately it only mentions Backend controllers in its title.

https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.5/Deprecation-84196-BackendControllerActionsDoNotReceivePreparedResponse.html

from rest.

cundd avatar cundd commented on August 23, 2024

The bug should be fixed in version 4 (commit 064a641). Would be great if you could test it.

from rest.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

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.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

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.

qbadev avatar qbadev commented on August 23, 2024

Thank You for all Your effort and quick fixes.

from rest.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

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.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

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.

qbadev avatar qbadev commented on August 23, 2024

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.

Docs here

from rest.

cundd avatar cundd commented on August 23, 2024

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.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

_count/: No I don't think so 😉

from rest.

qbadev avatar qbadev commented on August 23, 2024

It was discussed also on StackOverflow
Read here

from rest.

cundd avatar cundd commented on August 23, 2024

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.

qbadev avatar qbadev commented on August 23, 2024

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.

cundd avatar cundd commented on August 23, 2024

No problem!

from rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.