Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Hypermedia Links #690

Open
Mcklmo opened this issue Dec 26, 2024 · 0 comments
Open

Support for Hypermedia Links #690

Mcklmo opened this issue Dec 26, 2024 · 0 comments

Comments

@Mcklmo
Copy link

Mcklmo commented Dec 26, 2024

It would be useful to be able to link operations to another. Hypermedia links can link endpoints that are commonly used as follow-up to the current endpoint. The links could be defined on operation creation and be added to the API response automatically.

Example response to GET /users/1

{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]",
  "_links": {
    "self": {
      "href": "https://api.example.com/users/1"
    },
    "update": {
      "href": "https://api.example.com/users/1",
      "method": "PUT"
    },
    "delete": {
      "href": "https://api.example.com/users/1",
      "method": "DELETE"
    }
  }
}

This could, for example, be achieved by adding a parameter to the Operation struct that is called "HypermediaLinks" that takes a string slice of operation ids. On the api creation, it should panic if a linked operation is not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant