api

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeInvalidDiff = "invalid_diff"
	ErrCodeInvalidPath = "invalid_path"
)

Common error codes

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    string `tony:"name=code"`
	Message string `tony:"name=message"`
}

Error represents an API error response.

func NewError

func NewError(code, message string) *Error

NewError creates a new Error with the given code and message.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Is

func (e *Error) Is(target error) bool

Is implements the errors.Is interface for error matching.

func (*Error) MarshalText

func (e *Error) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It returns a structured format: "codeLength:code:message" or just "message" if no code. The length-prefixed format handles arbitrary message content including colons.

func (*Error) UnmarshalText

func (e *Error) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It parses the structured format: "codeLength:code:message" or just "message" if no code. The length-prefixed format handles arbitrary message content including colons.

type RequestBody

type RequestBody struct {
	Path  *ir.Node `tony:"name=path"`
	Match *ir.Node `tony:"name=match"`
	Patch *ir.Node `tony:"name=patch"`
	Meta  *ir.Node `tony:"name=meta"`
}

RequestBody represents the common structure for all requests using the path: match: patch: meta: layout.

func ParseRequestBody

func ParseRequestBody(r *http.Request) (*RequestBody, error)

ParseRequestBody parses the request body as a Tony document and extracts the RequestBody structure.

Jump to

Keyboard shortcuts

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