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

feat: add the management API (readonly). Generate the OpenAPI spec #154

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

Angelmmiguel
Copy link
Contributor

All the context is available in #153

Introduce a management API for Wasm Workers Server. For now, this API has only two endpoints:

  • /_api/v0/workers: returns all the workers in the current project.
  • /_api/v0/workers/{id}: returns the details of a worker like its configuration.

Currently, workers doesn't have any associated identifier (ID). I'm generating it by computing the SHA256 of the {project_root}/{file} path.

API Implementation

The API is split into two crates:

  • api-manage: contains the source code of the API. It includes the models and the handlers. It exposes a method to configure an app service with these new methods. By default, wws doesn't enable the management API.
  • api-manage-openapi: renders the OpenAPI specification from the api-manage and expose it. We will reuse this crate in the future to generate the CLI client in Rust (See Local panel to manage the current project #153).

To define the OpenAPI spec, I'm using utoipa, an amazing crate to generate OpenAPI specifications from rust web frameworks like Actix. I only need to add annotations to the methods and models and it generates all the information.

Note that utoipa exposes the OpenAPI spec as an HTTP endpoint, but we don't want to expose it for now. That's the reason we're using the api-manage-openapi spec crate to generate it into a file. The process is done in the build.rs file of that crate.

@Angelmmiguel Angelmmiguel added the 🚀 enhancement New feature or request label Jun 12, 2023
@Angelmmiguel Angelmmiguel added this to the v1.3.0 milestone Jun 12, 2023
@Angelmmiguel Angelmmiguel requested a review from a team June 12, 2023 11:21
@Angelmmiguel Angelmmiguel self-assigned this Jun 12, 2023
Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

Super! LGTM 👏

@Angelmmiguel Angelmmiguel merged commit 5941d1f into main Jun 12, 2023
@Angelmmiguel Angelmmiguel deleted the 153-initial-panel-api branch June 30, 2023 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants