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

Clnrest: dynamic paths #7529

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

daywalker90
Copy link
Contributor

based on #7507, #7508 and #7509

Adds the capability for clnrest to handle dynamic paths registered via a plugin's manifest. Supports the http methods GET and POST and arbitrary content-type's for responses. The most specific path is chosen if there are multiple matches.

lightningd is responsible for making sure no ambigous paths like /path/to/<me> and /path/to/<you> are registered.

@daywalker90 daywalker90 requested a review from cdecker as a code owner August 5, 2024 16:41
@daywalker90 daywalker90 force-pushed the clnrest-dynamic-routes branch from 35593be to 2e2d66e Compare August 5, 2024 16:49
Changelog-Added: clnrest: add support for dynamic paths
@daywalker90 daywalker90 force-pushed the clnrest-dynamic-routes branch from 2e2d66e to 8c16178 Compare August 5, 2024 16:51
@@ -131,7 +153,7 @@ async fn main() -> Result<(), anyhow::Error> {
"/v1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding v1 to all custom endpoints might prove problematic if someone's attempting to match an external spec.

In the case of cashu, which is currently v1, this is fine but in the case that cashu moves to v2 this will cause problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point. The versions are not correlated and could change independently. Do we need to add a version field to the clnrest manifest data?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's also possible to have specs that don't include the version part of the path!

I think there's two options here:

  • add an optional "version" field which defaults to the current CLN rest one. it can be set to 'null' which removes it entirely.
  • don't add the version to the endpoint but instead have rpcs add it to their path explicitly.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also would be problematic for cashu if clnrest moves to v2, but cashu does not

add an optional "version" field which defaults to the current CLN rest one. it can be set to 'null' which removes it entirely.

This would help maintain a static endpoint if clnrest bumps its version

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

Successfully merging this pull request may close these issues.

3 participants