jsonrpc

package
v0.0.0-...-3164695 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LOW_RESERVED_CODE             = -32768
	HIGH_RESERVED_CODE            = -32000
	PARSE_ERROR_CODE              = -32700
	PARSE_ERROR_MESSAGE           = "parse error"
	INVALID_REQUEST_CODE          = -32600
	INVALID_REQUEST_MESSAGE       = "invalid request"
	METHOD_NOT_FOUND_CODE         = -32601
	METHOD_NOT_FOUND_MESSAGE      = "method not found"
	METHOD_NOT_AUTHORIZED_CODE    = -32601
	METHOD_NOT_AUTHORIZED_MESSAGE = "method not authorized"
	INVALID_PARAMS_CODE           = -32602
	INVALID_PARAMS_MESSAGE        = "invalid params"
	INTERNAL_ERROR_CODE           = -32603
	INTERNAL_ERROR_MESSAGE        = "internal error"
)

Variables

This section is empty.

Functions

func Boolean

func Boolean(in any) bool

func DefaultTransport

func DefaultTransport(in []byte, tcontext any) (out []byte, err error)

func Duration

func Duration(in string, fallback float64) time.Duration

func DurationBounds

func DurationBounds(in string, fallback, lowest, highest float64) (out time.Duration)

func Handle

func Handle(in []byte, routes map[string]*ROUTE, filter func(string, any) bool, extra ...any) (out []byte)

func IntegerMap

func IntegerMap(in any, extra ...bool) (out map[string]int)

func KeysLength

func KeysLength(in any) (out int)

func Map

func Map(in any) (out map[string]any)

func MapKeys

func MapKeys(in any) (out []string)

func Number

func Number(in any, fallback ...float64) float64

func NumberMap

func NumberMap(in any, extra ...bool) (out map[string]float64)

func NumberSlice

func NumberSlice(in any, extra ...bool) (out []float64)

func NumberSliceItem

func NumberSliceItem(in []float64, index int) float64

func Request

func Request(calls []*CALL) (payload []byte, err error)

func Size

func Size(in string, fallback int64, extra ...bool) int64

func SizeBounds

func SizeBounds(in string, fallback, lowest, highest int64, extra ...bool) (out int64)

func Slice

func Slice(in any) (out []any)

func SliceItem

func SliceItem(in []any, index int) any

func String

func String(in any) string

func StringMap

func StringMap(in any, extra ...bool) (out map[string]string)

func StringSlice

func StringSlice(in any, extra ...bool) (out []string)

func StringSliceItem

func StringSliceItem(in []string, index int) string

func SwitchMap

func SwitchMap(in map[string]string) (out map[string]string)

Types

type CALL

type CALL struct {
	Method       string
	Params       any
	Notification bool
	Result       any
	Error        *ERROR
	Id           string
	// contains filtered or unexported fields
}

func Call

func Call(calls []*CALL, transport TRANSPORT, tcontext any) (results []*CALL, err error)

func Response

func Response(payload []byte, calls []*CALL) (results []*CALL, err error)

type CONTEXT_KEY

type CONTEXT_KEY string

type ERROR

type ERROR struct {
	Code    int
	Message string
	Data    any
}

type HANDLER

type HANDLER func(map[string]any, any) (any, *ERROR)

type REQUEST

type REQUEST struct {
	JSONRPC string
	Id      any
	Method  string
	Params  any
}

type RESPONSE

type RESPONSE struct {
	Id     any
	Result any
	Error  *ERROR
}

type ROUTE

type ROUTE struct {
	Handler HANDLER
	Context any
}

type TRANSPORT

type TRANSPORT func([]byte, any) ([]byte, error)

type TRANSPORT_OPTIONS

type TRANSPORT_OPTIONS struct {
	URL       string
	Headers   map[string]string
	Timeout   time.Duration
	Context   any
	Transport *http.Transport
}

Jump to

Keyboard shortcuts

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