Skip to content

refactor: move /api path prefix from config to code#138

Merged
fank merged 2 commits intomainfrom
refactor/api-server-url-config
Mar 2, 2026
Merged

refactor: move /api path prefix from config to code#138
fank merged 2 commits intomainfrom
refactor/api-server-url-config

Conversation

@fank
Copy link
Copy Markdown
Member

@fank fank commented Mar 2, 2026

Summary

  • api.serverUrl config now expects the base website URL (e.g. http://127.0.0.1:5000) without the /api suffix
  • The /api prefix is appended internally by the API client constructor and the websocket storage backend
  • Updated defaults, example config, docs, and tests accordingly

Test plan

  • All existing config and API client tests pass with updated expectations

The api.serverUrl config now expects just the base website URL
(e.g. http://127.0.0.1:5000) instead of including the /api suffix.
The /api prefix is appended internally by the API client and
websocket storage backend.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors how the /api path prefix is handled, moving its management from configuration to the application's code. This change streamlines the configuration by requiring only the base server URL, while the API client and websocket backend internally construct the full API endpoint. The primary impact is a cleaner and more consistent approach to API endpoint definition across the system, reducing potential configuration errors.

Highlights

  • Configuration Update: The api.serverUrl configuration now expects the base URL without the /api suffix, simplifying configuration.
  • Internal API Prefix Handling: The /api prefix is now appended internally by the API client constructor and the websocket storage backend, centralizing this logic in code.
  • Documentation and Test Alignment: Default values, example configurations, and existing tests have been updated to align with the new API URL handling.
Changelog
  • CLAUDE.md
    • Updated the example configuration for api.serverUrl to remove the /api suffix.
  • cmd/ocap_recorder/storage.go
    • Modified the websocket URL construction to internally append the /api prefix before the version stream.
  • internal/api/client.go
    • Updated the API client constructor to append /api to the baseURL internally, ensuring all API calls use the correct path.
  • internal/api/client_test.go
    • Adjusted test assertions for baseURL and request paths to reflect the new /api prefix handling by the API client.
  • internal/config/config.go
    • Changed the default value for api.serverUrl to exclude the /api suffix, aligning with the new configuration expectation.
  • ocap_recorder.cfg.json.example
    • Updated the example configuration file to reflect the new api.serverUrl format, removing the /api suffix.
Activity
  • The author has confirmed that all existing config and API client tests pass with the updated expectations, as indicated by the checked test plan item.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the application to move the /api path prefix from the configuration file into the code. The changes are consistent across the configuration, application code, and tests. My main feedback is to address the duplication of the "/api" string literal, which now appears in both the API client constructor and the WebSocket storage backend. Consolidating this into a single constant would improve maintainability.

Comment thread cmd/ocap_recorder/storage.go Outdated
Comment thread internal/api/client.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/extension/v5/cmd/ocap_recorder 0.00% (ø)
github.com/OCAP2/extension/v5/internal/api 94.00% (+4.00%) 👍
github.com/OCAP2/extension/v5/internal/config 97.56% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/extension/v5/cmd/ocap_recorder/storage.go 0.00% (ø) 0 0 0
github.com/OCAP2/extension/v5/internal/api/client.go 94.00% (+4.00%) 50 47 (+2) 3 (-2) 👍
github.com/OCAP2/extension/v5/internal/config/config.go 97.56% (ø) 41 40 1

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/OCAP2/extension/v5/internal/api/client_test.go
  • github.com/OCAP2/extension/v5/internal/config/config_test.go

@fank fank merged commit 4f5a7ed into main Mar 2, 2026
3 checks passed
@fank fank deleted the refactor/api-server-url-config branch March 2, 2026 12:13
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.

1 participant