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

re-use static strings for paths #13

Merged
merged 4 commits into from
Nov 27, 2023
Merged

re-use static strings for paths #13

merged 4 commits into from
Nov 27, 2023

Conversation

tluijken
Copy link
Collaborator

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Code refactoring

⤵️ What is the current behavior?

Currently, there a a get_path method added to the Request trait, which is only used internally within the request to get the path. This path is often shared between multiple requests sharing the same controller. I think this is a wrong design, and doesn't allow for a proper re-use of path strings, which we should define one, and use as a const value.

🆕 What is the new behavior (if this is a feature change)?

The paths for a particular module are not defined as const values, and can be re-used for multiple request reaching out to the same endpoint.

💥 Does this PR introduce a breaking change?

No

🐛 Recommendations for testing

The unit-tests still cover the logic.

📝 Links to relevant issues/docs

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines
  • Relevant documentation was updated
  • Rebased onto current main

Copy link
Contributor

@ejorritsma ejorritsma left a comment

Choose a reason for hiding this comment

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

Heel clean! Nice.

src/ledgers/single_ledger_request.rs Show resolved Hide resolved
src/ledgers/mod.rs Show resolved Hide resolved
self.liquidity_pool
.as_ref()
.map(|lp| format!("liquidity_pool={}", lp)),
].build_query_parameters()
}

fn build_url(&self, base_url: &str) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this function is largely the same accross endpoints.
Some format with "{}/{}/{}" and some with "{}/{}{}".
Maybe (in another PR) we can unify this one as well :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would agree on that!

@tluijken tluijken merged commit cc7b018 into main Nov 27, 2023
1 check passed
@tluijken tluijken deleted the constant-strings branch November 27, 2023 12:35
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.

2 participants