go icon indicating copy to clipboard operation
go copied to clipboard

Add Flag to truncate full href URL in responses

Open sydneynotthecity opened this issue 1 year ago • 0 comments

What problem does your feature solve?

Infrastructure providers like Quicknode return the physical API address in href attributes in the Horizon URL. When testing a Horizon endpoint, we noticed the following response from Quicknode:

{
  "_links": {
    "self": {
      "href": "http://129.213.32.131:8000/ledgers?cursor=\u0026limit=10\u0026order=desc"
    },
    "next": {
      "href": "http://129.213.32.131:8000/ledgers?cursor=5968462648180736\u0026limit=10\u0026order=desc"
    },
    "prev": {
      "href": "http://129.213.32.131:8000/ledgers?cursor=5968501302886400\u0026limit=10\u0026order=asc"
    }

These URLs are unusable for end users, but would require Quicknode to rewrite all responses to clients because they have a shared pool for the API. They would like to avoid rewriting those responses because it would increase response time on their infra, increase resource usage, and introduces risks for bugs to appear.

What would you like to see?

Instead of the current API response, with full URLs, is it possible to truncate those? Using /ledgers as an example:

{
  "_links": {
    "self": {
      "href": "https://horizon-testnet.stellar.org/ledgers/1389641"
    },
    "transactions": {
      "href": "[https://horizon-testnet.stellar.org/ledgers/1389641/transactions{?cursor,limit,order}](https://horizon-testnet.stellar.org/ledgers/1389641/transactions%7B?cursor,limit,order})",
      "templated": true
    },

would instead become:

{
  "_links": {
    "self": {
      "href": "/ledgers/1389641"
    },
    "transactions": {
      "href": "[/ledgers/1389641/transactions{?cursor,limit,order}](/ledgers/1389641/transactions%7B?cursor,limit,order})",
      "templated": true
    },

Users would need to append the path into their endpoint, but it would save infra providers resources and maintenance work to rewrite the URLs. This would add little effort for the end user and improve current UX.

What alternatives are there?

Quicknode could handle the URLs themselves with a custom fix to Horizon, but this is not prioritized work or a viable option in their current roadmap.

sydneynotthecity avatar Sep 08 '23 17:09 sydneynotthecity