rpc

package
v1.239.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) int

Code from the error, otherwise 500.

func Error

func Error(code int, msg string) error

Error representing code and msg.

func Handle

func Handle[Req any, Res any](path string, handler Handler[Req, Res])

Handler for HTTP.

func IsError

func IsError(err error) bool

IsError verifies if the package created this error.

func Register

func Register(mu *http.ServeMux, ma *marshaller.Map)

Register for HTTP.

Types

type Client

type Client[Req any, Res any] struct {
	// contains filtered or unexported fields
}

Client for HTTP.

func NewClient

func NewClient[Req any, Res any](url, contentType string, client *http.Client, mar *marshaller.Map) *Client[Req, Res]

NewClient for HTTP.

func (*Client[Req, Res]) Call

func (c *Client[Req, Res]) Call(ctx context.Context, req *Req) (res *Res, err error)

Call for HTTP.

type Context

type Context interface {
	// Request of the context.
	Request() *http.Request

	// Response of the context.
	Response() http.ResponseWriter

	context.Context
}

Context for HTTP.

type Handler

type Handler[Req any, Res any] interface {
	// Handle func for request/response.
	Handle(ctx Context, req *Req) (*Res, error)
}

Handler for HTTP.

Jump to

Keyboard shortcuts

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