Repository navigation
Implements Worker script upload methods - #74
Merged
Merged
Conversation
Adds `upload` and `updateContent` methods to the Workers `Scripts` endpoint, and `update` to the `Environment` endpoint, while integrating the existing `Versions::upload` method. Introduces a shared `UploadsModules` trait to handle Cloudflare's multipart upload format for Workers, which supports multiple modules and distinct metadata. This enables: - Full script and configuration replacement (`scripts::upload`) - Code-only updates, preserving configuration (`scripts::updateContent`, `environment::update`) - Uploading new Worker versions (`versions::upload`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the implementation for uploading Worker scripts and their content across various endpoints:
Workers\Environment::update: Replaces the code of a Worker in a given environment, preserving existing settings and bindings.Workers\Scripts::upload: Uploads a Worker, replacing its script and full configuration (bindings, compatibility date, etc.). This method expects a complete configuration to be sent.Workers\Scripts::updateContent: Replaces only a Worker's code, leaving its configuration and metadata untouched.Workers\Versions::upload: Now utilizes the shared helper for building multipart upload requests.Introduces a new
UploadsModulestrait to centralize the logic for constructing multipart HTTP bodies required for uploading Worker modules and their associated metadata. This enhances code reusability, ensures consistent request formatting, and includes validation for module data.Documentation, including usage examples and parameter tables, has been updated for all modified methods. New tests have been added to verify the correct functionality of these multipart upload operations. API coverage for the Workers resource has increased as a result of these additions.