http

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPFormatter

func HTTPFormatter(m *Message, code int, headers map[string]string, body interface{})

func JsonRPCFormatter

func JsonRPCFormatter(m *Message, code int, headers map[string]string, body interface{})

Types

type CallFunc added in v1.8.0

type CallFunc func(*Message) error

type FormatterFunc added in v1.8.0

type FormatterFunc func(m *Message, code int, headers map[string]string, body interface{})

type Handler added in v1.8.0

type Handler struct {
	Method string
	Path   string
	Call   CallFunc
}

type JsonRPCErrorBody

type JsonRPCErrorBody struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (JsonRPCErrorBody) MarshalEasyJSON

func (v JsonRPCErrorBody) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCErrorBody) MarshalJSON

func (v JsonRPCErrorBody) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*JsonRPCErrorBody) UnmarshalEasyJSON

func (v *JsonRPCErrorBody) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCErrorBody) UnmarshalJSON

func (v *JsonRPCErrorBody) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type JsonRPCRequest

type JsonRPCRequest struct {
	ID     string          `json:"id"`
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

func (JsonRPCRequest) MarshalEasyJSON

func (v JsonRPCRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCRequest) MarshalJSON

func (v JsonRPCRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*JsonRPCRequest) UnmarshalEasyJSON

func (v *JsonRPCRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCRequest) UnmarshalJSON

func (v *JsonRPCRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type JsonRPCResponse

type JsonRPCResponse struct {
	ID     string          `json:"id"`
	Result json.RawMessage `json:"result"`
}

func (JsonRPCResponse) MarshalEasyJSON

func (v JsonRPCResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCResponse) MarshalJSON

func (v JsonRPCResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*JsonRPCResponse) UnmarshalEasyJSON

func (v *JsonRPCResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCResponse) UnmarshalJSON

func (v *JsonRPCResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type JsonRPCResponseError

type JsonRPCResponseError struct {
	ID    string           `json:"id"`
	Error JsonRPCErrorBody `json:"error"`
}

func (JsonRPCResponseError) MarshalEasyJSON

func (v JsonRPCResponseError) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCResponseError) MarshalJSON

func (v JsonRPCResponseError) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*JsonRPCResponseError) UnmarshalEasyJSON

func (v *JsonRPCResponseError) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCResponseError) UnmarshalJSON

func (v *JsonRPCResponseError) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Message

type Message struct {
	Writer    http.ResponseWriter
	Reader    *http.Request
	Formatter FormatterFunc
}

func (*Message) Decode

func (m *Message) Decode(call func([]byte) error) error

func (*Message) Empty

func (m *Message) Empty(code int)

func (*Message) Encode

func (m *Message) Encode(call func() (int, map[string]string, interface{}))

func (*Message) Error

func (m *Message) Error(code int, err error)

func (*Message) GetCookies

func (m *Message) GetCookies() map[string]*http.Cookie

func (*Message) Redirect

func (m *Message) Redirect(url string)

func (*Message) SetCookie

func (m *Message) SetCookie(key, value string, ttl time.Duration)

type ModuleInjecter added in v1.8.0

type ModuleInjecter interface {
	Handlers() []Handler
	Formatter() FormatterFunc
	Middleware() CallFunc
}

type Route added in v1.8.0

type Route struct {
	Call       CallFunc
	Middleware CallFunc
	Formatter  FormatterFunc
}

type Router added in v1.8.0

type Router struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRouter added in v1.8.0

func NewRouter() *Router

func (*Router) Add added in v1.8.0

func (h *Router) Add(hhi ModuleInjecter)

func (*Router) ServeHTTP added in v1.8.0

func (h *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Server

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

func NewServer added in v1.8.0

func NewServer() *Server

func (*Server) AddRoute added in v1.8.0

func (s *Server) AddRoute(hhi ModuleInjecter)

func (*Server) Down

func (s *Server) Down() error

func (*Server) SetAddr

func (s *Server) SetAddr(addr string)

func (*Server) Up

func (s *Server) Up() error

Jump to

Keyboard shortcuts

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