Skip to content

Add initial implementation of API #320

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add initial implementation of API #320

wants to merge 2 commits into from

Conversation

JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented May 2, 2025

This adds an initial implementation of an API for ToolHive, it implements a "local"
client that simply runs everything in-process. Most subcommands of thv are now using
this except for thv run which is more complex and merits dedicated work.

The intention is to take the local server and wrap it with an HTTP implementation so
we could have a REST API. Maybe in the future we'll also have a gRPC implementation.

Related-to: #310

JAORMX added 2 commits May 2, 2025 16:51
…ntation

This commit introduces a versioned API structure for ToolHive that follows
Go best practices for API design. The API provides a clean separation between
the public interface and the internal implementation, allowing each to evolve
independently.

Key changes:
- Create versioned API package structure (pkg/api/v1)
- Define comprehensive API types with interfaces
- Implement conversion functions between API and internal types
- Fix all linting issues in the implementation

The API is organized into:
1. Types (pkg/api/v1/types.go) - Data structures used in the API
2. Interfaces (pkg/api/v1/api.go) - API contract definitions
3. Conversion (pkg/api/v1/convert/*) - Type conversion functions

This design provides several benefits:
- API stability through versioning
- Implementation freedom through separation
- Clear boundaries between client and server
- Self-documenting through Go doc comments

The actual implementation of the API functionality will be added in
subsequent commits.

Signed-off-by: Juan Antonio Osorio <[email protected]>
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