You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi
(this might be more out of ignorance on my side than a topic for issue in restish)
I am trying to add a new AddLinkParser to restish to handle pagination in a vendors API (link https://cyber-risk.upguard.com/api/docs). The API in question just returns a counter to the next page token and its fairly easy to build the link the next page out of it. So for example, a query to /domains returns a JSON with next_page_token: 1000 and total_results: 15723
then the next page link would simply be /domains?page_token={next_page_token}
in m code (myparsers), as the myparsers.ParseLinks function has only the query response to work from, I have been setting the the next link by putting the link URI to "?page_token=" + b["next_page_token"].(string), leaving it to restish "links.ParseLink" (in links.go+49) function to build a complete URI using ResolveReference.
So far, so good. This has proven to be fairly easy and working as expected with one gotcha: if my original query contains any parameters, then the ResolveReference squashes those parameters making the Link URI not representative of my original query.
Hence this feature request: make linkparsers take response and request as arguments
If the ParseLinks function being called would have the response and the (original) request as arguments it would allow to build more complex "next" page URIs .
Tx
The text was updated successfully, but these errors were encountered:
hi
(this might be more out of ignorance on my side than a topic for issue in restish)
I am trying to add a new AddLinkParser to restish to handle pagination in a vendors API (link https://cyber-risk.upguard.com/api/docs). The API in question just returns a counter to the next page token and its fairly easy to build the link the next page out of it. So for example, a query to /domains returns a JSON with next_page_token: 1000 and total_results: 15723
then the next page link would simply be /domains?page_token={next_page_token}
in m code (myparsers), as the myparsers.ParseLinks function has only the query response to work from, I have been setting the the next link by putting the link URI to "?page_token=" + b["next_page_token"].(string), leaving it to restish "links.ParseLink" (in links.go+49) function to build a complete URI using ResolveReference.
So far, so good. This has proven to be fairly easy and working as expected with one gotcha: if my original query contains any parameters, then the ResolveReference squashes those parameters making the Link URI not representative of my original query.
Hence this feature request: make linkparsers take response and request as arguments
If the ParseLinks function being called would have the response and the (original) request as arguments it would allow to build more complex "next" page URIs .
Tx
The text was updated successfully, but these errors were encountered: