Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

📝 Add docstrings to delete-handler #13

Open
wants to merge 1 commit into
base: delete-handler
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion zipserver/delete_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ type DeleteResult struct {
Error string `json:"error,omitempty"`
}

// deleteHandler handles the deletion of files specified by an array of keys
// deleteHandler handles bulk deletion of files from a specified storage target.
// It processes an HTTP request with an array of keys to delete, validates the storage target,
// and performs concurrent file deletions with optional asynchronous callback notification.
//
// The function supports two modes of operation:
// 1. Synchronous: Returns immediate results of deletion attempts
// 2. Asynchronous: Sends results to a specified callback URL while returning an immediate response
//
// Parameters:
// - w: HTTP response writer for sending the response
// - r: HTTP request containing deletion parameters
//
// Request form parameters:
// - keys[]: Array of file keys to delete (required)
// - target: Name of the storage target (required)
// - callback: Optional URL to receive asynchronous deletion results
//
// Returns an error if request parsing, parameter validation, or processing fails.
// Handles concurrent deletions with per-key locking to prevent race conditions.
func deleteHandler(w http.ResponseWriter, r *http.Request) error {
err := r.ParseForm()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion zipserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func statusHandler(w http.ResponseWriter, r *http.Request) error {
})
}

// StartZipServer starts listening for extract and slurp requests
// Returns an error if the server fails to start or listen on the specified address.
func StartZipServer(listenTo string, _config *Config) error {
globalConfig = _config

Expand Down