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

fix(BUX-497): Routes are hardcoded instead of initialized by configured capabilities #71

Merged
merged 8 commits into from
Jan 22, 2024

Conversation

chris-4chain
Copy link
Contributor

@chris-4chain chris-4chain commented Jan 19, 2024

Pull Request Checklist

  • πŸ“– I created my PR using provided : CODE_STANDARDS
  • πŸ“– I have read the short Code of Conduct: CODE_OF_CONDUCT
  • 🏠 I tested my changes locally.
  • βœ… I have provided tests for my changes.
  • πŸ“ I have used conventional commits.
  • πŸ“— I have updated any related documentation.
  • πŸ’Ύ PR was issued based on the Github or Jira issue.

Initially, the main task was to fix the bug that the routes of capabilities were hardcoded, regardless of what was configured.
That led to introduce CallableCapability & StaticCapability types, which are used to configure capabilities and automatically configure the router.

TL;DR What has been done:

  1. Single point capabilities definition
  • two types of capabilities
    • CallableCapability - has its own http endpoint
    • StaticCapability - it is a parameter which is visible in json response of /.well-known/bsvalias (for now, we have only one static capability - BRFCSenderValidation)
  • With* config functions which previously manipulated the CapabilitiesPaylod, now set appropriate boolean flags in Configuration struct
  • Previously, the WithCapabilities config function did not make much sense, because although it was possible to add custom capabilities, the hard-coded router was not able to handle them.
    • Now, since the router is automatically generated based on the CallableCapability'ies, which contain handlers for each capability, it is possible to add custom capabilities which will be automatically configured by the router.
  • Tests have been adjusted
  • In server.server_test.go there was a commented out test, named 'run server'
    • I made it work and developed it a bit further, so that it tests whether the server is running and /.well-known/ endpoint as well as all discovered capabilities are available
    • I used net/http/httptest package to test the server
  • I made the run_server example work on localhost with additional&optional custom capabilities
  • Function showCapabilities and method EnrichCapabilities have been refactored and adjusted to the new capabilities concept
  • Several minor TODOs have been resolved
  • There was an additional bug I fixed:
    • when server was listening on some port (let's say 8080), the links in service discovery were pointing to correct domain but without port.

@chris-4chain chris-4chain requested a review from a team as a code owner January 19, 2024 13:37
server/config.go Outdated Show resolved Hide resolved
@chris-4chain chris-4chain merged commit 8e14dd0 into main Jan 22, 2024
2 checks passed
@chris-4chain chris-4chain deleted the fix-497-capabilities branch January 22, 2024 14:28
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