api

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 9 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 Body added in v0.0.7

type Body struct {
	Path string   `tony:"field=path"`
	Data *ir.Node `tony:"field=data"`
}

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

func ParseRequestBody

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

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

func (*Body) FromTony added in v0.0.7

func (s *Body) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates Body.

func (*Body) FromTonyIR added in v0.0.7

func (s *Body) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates Body from a Tony IR node.

func (*Body) ToTony added in v0.0.7

func (s *Body) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts Body to Tony format bytes.

func (*Body) ToTonyIR added in v0.0.7

func (s *Body) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts Body to a Tony IR node.

type Duration added in v0.0.10

type Duration time.Duration

func (Duration) MarshalText added in v0.0.10

func (dur Duration) MarshalText() ([]byte, error)

func (*Duration) UnmarshalText added in v0.0.10

func (dur *Duration) UnmarshalText(d []byte) error

type EncodingOptions added in v0.0.7

type EncodingOptions struct {
	Wire     bool `tony:"field=wire"`
	Brackets bool `tony:"field=brackets"`
}

func (*EncodingOptions) FromTony added in v0.0.7

func (s *EncodingOptions) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates EncodingOptions.

func (*EncodingOptions) FromTonyIR added in v0.0.7

func (s *EncodingOptions) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates EncodingOptions from a Tony IR node.

func (*EncodingOptions) ToTony added in v0.0.7

func (s *EncodingOptions) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts EncodingOptions to Tony format bytes.

func (*EncodingOptions) ToTonyIR added in v0.0.7

func (s *EncodingOptions) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts EncodingOptions to a Tony IR node.

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) FromTony added in v0.0.7

func (s *Error) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates Error.

func (*Error) FromTonyIR added in v0.0.7

func (s *Error) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates Error from a Tony IR node.

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) ToTony added in v0.0.7

func (s *Error) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts Error to Tony format bytes.

func (*Error) ToTonyIR added in v0.0.7

func (s *Error) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts Error to a Tony IR node.

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 Match added in v0.0.7

type Match struct {
	Meta MatchMeta `tony:"field=meta"`
	Body Body      `tony:"field=body"`
}

func (*Match) FromTony added in v0.0.7

func (s *Match) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates Match.

func (*Match) FromTonyIR added in v0.0.7

func (s *Match) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates Match from a Tony IR node.

func (*Match) ToTony added in v0.0.7

func (s *Match) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts Match to Tony format bytes.

func (*Match) ToTonyIR added in v0.0.7

func (s *Match) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts Match to a Tony IR node.

type MatchMeta added in v0.0.7

type MatchMeta struct {
	EncodingOptions
	SeqID *int64 `tony:"field=seq"`
}

func (*MatchMeta) FromTony added in v0.0.7

func (s *MatchMeta) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates MatchMeta.

func (*MatchMeta) FromTonyIR added in v0.0.7

func (s *MatchMeta) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates MatchMeta from a Tony IR node.

func (*MatchMeta) ToTony added in v0.0.7

func (s *MatchMeta) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts MatchMeta to Tony format bytes.

func (*MatchMeta) ToTonyIR added in v0.0.7

func (s *MatchMeta) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts MatchMeta to a Tony IR node.

type Patch added in v0.0.7

type Patch struct {
	Meta  PatchMeta `tony:"field=meta"`
	Match *Body     `tony:"field=match"`
	Patch Body      `tony:"field=patch"`
}

func (*Patch) FromTony added in v0.0.7

func (s *Patch) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates Patch.

func (*Patch) FromTonyIR added in v0.0.7

func (s *Patch) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates Patch from a Tony IR node.

func (*Patch) ToTony added in v0.0.7

func (s *Patch) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts Patch to Tony format bytes.

func (*Patch) ToTonyIR added in v0.0.7

func (s *Patch) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts Patch to a Tony IR node.

type PatchMeta added in v0.0.7

type PatchMeta struct {
	EncodingOptions
	Tx          *string  `tony:"field=tx"`
	MaxDuration Duration `tony:"field=maxDuration"`
	Seq         *int64   `tony:"field=seq"` // Seq when supplied asserts that seq is the latest value for patched data, on return, if successful, seq shows the commit resulting from applying the changes.

	When *time.Time `tony:"field=when"`
}

func (*PatchMeta) FromTony added in v0.0.7

func (s *PatchMeta) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates PatchMeta.

func (*PatchMeta) FromTonyIR added in v0.0.7

func (s *PatchMeta) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates PatchMeta from a Tony IR node.

func (*PatchMeta) ToTony added in v0.0.7

func (s *PatchMeta) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts PatchMeta to Tony format bytes.

func (*PatchMeta) ToTonyIR added in v0.0.7

func (s *PatchMeta) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts PatchMeta to a Tony IR node.

type WatchMeta added in v0.0.7

type WatchMeta struct {
	EncodingOptions
	From *int64 `tony:"field=from"`
	To   *int64 `tony:"field=to"`
}

func (*WatchMeta) FromTony added in v0.0.7

func (s *WatchMeta) FromTony(data []byte, opts ...gomap.UnmapOption) error

FromTony parses Tony format bytes and populates WatchMeta.

func (*WatchMeta) FromTonyIR added in v0.0.7

func (s *WatchMeta) FromTonyIR(node *ir.Node, opts ...gomap.UnmapOption) error

FromTonyIR populates WatchMeta from a Tony IR node.

func (*WatchMeta) ToTony added in v0.0.7

func (s *WatchMeta) ToTony(opts ...gomap.MapOption) ([]byte, error)

ToTony converts WatchMeta to Tony format bytes.

func (*WatchMeta) ToTonyIR added in v0.0.7

func (s *WatchMeta) ToTonyIR(opts ...gomap.MapOption) (*ir.Node, error)

ToTonyIR converts WatchMeta to a Tony IR node.

Jump to

Keyboard shortcuts

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