Back to

Package xecho

Latest Go to latest

The latest major version is .

Published: Sep 7, 2020 | License: Apache-2.0 | Module:



const (
	// HeaderAcceptEncoding ...
	HeaderAcceptEncoding = "Accept-Encoding"
	// HeaderContentType ...
	HeaderContentType = "Content-Type"
	// HRPC Errord
	HeaderHRPCErr = "HRPC-Errord"


const (
	// MIMEApplicationJSON ...
	MIMEApplicationJSON = "application/json"
	// MIMEApplicationJSONCharsetUTF8 ...
	MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8
	// MIMEApplicationProtobuf ...
	MIMEApplicationProtobuf = "application/protobuf"

MIME types

const ModName = "server.echo"

ModName named a mod


var (
	// ErrGRPCResponseValid ...
	ErrGRPCResponseValid = grpc.Errorf(codes.Internal, "response valid")
	// ErrGRPCInvokeLen ...
	ErrGRPCInvokeLen = grpc.Errorf(codes.Internal, "invoke request without len 2 res")
var ErrNotFound = HTTPError{
	Code:    http.StatusNotFound,
	Message: "not found",

ErrNotFound defines StatusNotFound error.

func GRPCProxyWrapper

func GRPCProxyWrapper(h interface{}) echo.HandlerFunc

GRPCProxyWrapper ...

func ProtoError

func ProtoError(c echo.Context, code int, e error) error

ProtoError ...

func ProtoJSON

func ProtoJSON(c echo.Context, code int, i interface{}) error

ProtoJSON sends a Protobuf JSON response with status code and data.

type Config

type Config struct {
	Host          string
	Port          int
	Deployment    string
	Debug         bool
	DisableMetric bool
	DisableTrace  bool

	SlowQueryThresholdInMilli int64
	// contains filtered or unexported fields

Config HTTP config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

func RawConfig

func RawConfig(key string) *Config

RawConfig ...

func StdConfig

func StdConfig(name string) *Config

StdConfig Jupiter Standard HTTP Server config

func (*Config) Address

func (config *Config) Address() string

Address ...

func (*Config) Build

func (config *Config) Build() *Server

Build create server instance, then initialize it with necessary interceptor

func (*Config) WithHost

func (config *Config) WithHost(host string) *Config

WithHost ...

func (*Config) WithLogger

func (config *Config) WithLogger(logger *xlog.Logger) *Config

WithLogger ...

func (*Config) WithPort

func (config *Config) WithPort(port int) *Config

WithPort ...

type EmptyMessage

type EmptyMessage struct{}

EmptyMessage ...

func (*EmptyMessage) ProtoMessage

func (*EmptyMessage) ProtoMessage()

ProtoMessage ...

func (*EmptyMessage) Reset

func (m *EmptyMessage) Reset()

Reset ...

func (*EmptyMessage) String

func (m *EmptyMessage) String() string

String ...

type GRPCProxyMessage

type GRPCProxyMessage struct {
	Error   int           `protobuf:"varint,1,opt,name=error" json:"error"`
	Message string        `protobuf:"bytes,2,opt,name=msg" json:"msg"`
	Data    proto.Message `protobuf:"bytes,3,opt,name=data" json:"data"`

GRPCProxyMessage ...

func (*GRPCProxyMessage) MarshalJSONPB

func (m *GRPCProxyMessage) MarshalJSONPB(jsb *jsonpb.Marshaler) ([]byte, error)

MarshalJSONPB ...

func (*GRPCProxyMessage) ProtoMessage

func (*GRPCProxyMessage) ProtoMessage()

ProtoMessage ...

func (*GRPCProxyMessage) Reset

func (m *GRPCProxyMessage) Reset()

Reset ...

func (*GRPCProxyMessage) String

func (m *GRPCProxyMessage) String() string

String ...

type HTTPError

type HTTPError struct {
	Code    int
	Message string

HTTPError wraps handler error.

func NewHTTPError

func NewHTTPError(code int, msg ...string) *HTTPError

NewHTTPError constructs a new HTTPError instance.

func (HTTPError) Error

func (e HTTPError) Error() string

Errord return error message.

type Server

type Server struct {
	// contains filtered or unexported fields

Server ...

func (*Server) GracefulStop

func (s *Server) GracefulStop(ctx context.Context) error

GracefulStop implements server.Server interface it will stop echo server gracefully

func (*Server) Info

func (s *Server) Info() *server.ServiceInfo

Info returns server info, used by governor and consumer balancer

func (*Server) Serve

func (s *Server) Serve() error

Server implements server.Server interface.

func (*Server) Stop

func (s *Server) Stop() error

Stop implements server.Server interface it will terminate echo server immediately

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier