xhttp

package
v0.0.0-...-124caa8 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ArgsQuery  = "xhttp-query"
	ArgsHeader = "xhttp-header"
)

Variables

View Source
var ErrAuthFailed = errors.New("auth failed")
View Source
var ErrRejectHandle = errors.New("reject handle")

Functions

func SetArgsHeader

func SetArgsHeader(ctx context.Context, header http.Header) context.Context

func SetArgsQuery

func SetArgsQuery(ctx context.Context, values url.Values) context.Context

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *ClientConfig) *Client

func (*Client) Call

func (c *Client) Call(ctx context.Context, name string, data any) (io.ReadCloser, error)

func (*Client) CallAny

func (c *Client) CallAny(ctx context.Context, name string, data, out any) error

func (*Client) CallBytes

func (c *Client) CallBytes(ctx context.Context, name string, data any) ([]byte, error)

func (*Client) Close

func (c *Client) Close()

type ClientConfig

type ClientConfig struct {
	Dr     xnetutil.Dialer
	TlsCfg *tls.Config
	Auth   *struct {
		AuthUserName string
		AuthPassword string
	}
	Prefix string
	Host   string
}

type Config

type Config struct {
	Ctx    context.Context
	Type   Type
	TlsCfg *tls.Config
	Auth   func(u, p string) bool
	Prefix string
}

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func (*Context) Bind

func (c *Context) Bind(a any) error

func (*Context) Query

func (c *Context) Query() url.Values

func (*Context) RHeader

func (c *Context) RHeader() http.Header

func (*Context) WHeader

func (c *Context) WHeader() http.Header

func (*Context) Write

func (c *Context) Write(b []byte) (int, error)

func (*Context) WriteAny

func (c *Context) WriteAny(a any) error

func (*Context) WriteFlush

func (c *Context) WriteFlush(b []byte) (int, error)

func (*Context) WriteLn

func (c *Context) WriteLn(b []byte) (int, error)

func (*Context) WriteString

func (c *Context) WriteString(s string) (int, error)

func (*Context) WriteStringLn

func (c *Context) WriteStringLn(s string) (int, error)

type Handler

type Handler func(*Context) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *Config) *Server

func (*Server) AutoServe

func (s *Server) AutoServe(ln net.Listener) error

AutoServe if had tls config will be used

func (*Server) Close

func (s *Server) Close() error

func (*Server) Context

func (s *Server) Context() context.Context

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

func (*Server) ServeTLS

func (s *Server) ServeTLS(l net.Listener, certFile string, keyFile string) error

func (*Server) Set

func (s *Server) Set(name string, handlers ...Handler)

type Type

type Type uint8
const (
	TypeNone Type = iota
	TypeMuxReject
	TypeMuxWait
)

Jump to

Keyboard shortcuts

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