autopatch

package
v2.0.0-...-21a9387 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package autopatch provides a way to automatically generate PATCH operations for resources which have a GET & PUT but no PATCH. This is useful for resources which are large and have many fields, but where the majority of updates are only to a few fields. This allows clients to send a partial update to the server without having to send the entire resource.

JSON Merge Patch, JSON Patch, and Shorthand Merge Patch are supported as input formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoPatch

func AutoPatch(api huma.API)

AutoPatch generates HTTP PATCH operations for any resource which has a GET & PUT but no pre-existing PATCH operation. Generated PATCH operations will call GET, apply either `application/merge-patch+json`, `application/json-patch+json`, or `application/merge-patch+shorthand` patches, then call PUT with the updated resource. This method may be safely called multiple times.

If you wish to disable autopatching for a specific resource, set the `autopatch` operation metadata field to `false` on the GET or PUT operation and it will be skipped.

func PatchResource

func PatchResource(api huma.API, path *huma.PathItem)

PatchResource is called for each resource which needs a PATCH operation to be added. It registers and provides a handler for this new operation. You may call this manually if you prefer to not use `AutoPatch` for all of your resources and want more fine-grained control.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL