http

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 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 added in v1.6.0

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

func JsonRPCFormatter added in v1.6.0

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

Types

type CallHandler added in v1.6.0

type CallHandler struct {
	Method string
	Path   string
	Call   FN
}

type FMT added in v1.6.0

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

type FN added in v1.6.0

type FN func(*Message) error

type HttpHandler

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

func NewHttpHandler

func NewHttpHandler() *HttpHandler

func (*HttpHandler) Route

func (h *HttpHandler) Route(hhi HttpHandlerInterface)

func (*HttpHandler) ServeHTTP

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

type HttpHandlerInterface added in v1.6.0

type HttpHandlerInterface interface {
	Handlers() []CallHandler
	Formatter() FMT
	Middelware() FN
}

type HttpHandlerItem added in v1.6.0

type HttpHandlerItem struct {
	Call       FN
	Middelware FN
	Formatter  FMT
}

type JsonRPCErrorBody added in v1.6.0

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

func (JsonRPCErrorBody) MarshalEasyJSON added in v1.6.0

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCErrorBody) MarshalJSON added in v1.6.0

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

MarshalJSON supports json.Marshaler interface

func (*JsonRPCErrorBody) UnmarshalEasyJSON added in v1.6.0

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCErrorBody) UnmarshalJSON added in v1.6.0

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

UnmarshalJSON supports json.Unmarshaler interface

type JsonRPCRequest added in v1.6.0

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

func (JsonRPCRequest) MarshalEasyJSON added in v1.6.0

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCRequest) MarshalJSON added in v1.6.0

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

MarshalJSON supports json.Marshaler interface

func (*JsonRPCRequest) UnmarshalEasyJSON added in v1.6.0

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCRequest) UnmarshalJSON added in v1.6.0

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

UnmarshalJSON supports json.Unmarshaler interface

type JsonRPCResponse added in v1.6.0

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

func (JsonRPCResponse) MarshalEasyJSON added in v1.6.0

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCResponse) MarshalJSON added in v1.6.0

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

MarshalJSON supports json.Marshaler interface

func (*JsonRPCResponse) UnmarshalEasyJSON added in v1.6.0

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCResponse) UnmarshalJSON added in v1.6.0

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

UnmarshalJSON supports json.Unmarshaler interface

type JsonRPCResponseError added in v1.6.0

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

func (JsonRPCResponseError) MarshalEasyJSON added in v1.6.0

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (JsonRPCResponseError) MarshalJSON added in v1.6.0

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

MarshalJSON supports json.Marshaler interface

func (*JsonRPCResponseError) UnmarshalEasyJSON added in v1.6.0

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JsonRPCResponseError) UnmarshalJSON added in v1.6.0

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

UnmarshalJSON supports json.Unmarshaler interface

type Message

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

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 added in v1.6.0

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

func (*Message) GetCookies added in v1.6.2

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

func (*Message) Redirect added in v1.6.2

func (m *Message) Redirect(url string)

func (*Message) SetCookie added in v1.6.2

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

type Server

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

func New

func New() *Server

func (*Server) Down

func (s *Server) Down() error

func (*Server) Route

func (s *Server) Route(hhi HttpHandlerInterface)

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