xecho

package
v0.11.15 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 43 Imported by: 34

Documentation

Index

Constants

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

Headers

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

MIME types

Variables

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

ErrNotFound defines StatusNotFound error.

Functions

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.

Types

type BindUnmarshaler added in v0.10.2

type BindUnmarshaler = echo.BindUnmarshaler

BindUnmarshaler is the interface used to wrap the UnmarshalParam method. Types that don't implement this, but do implement encoding.TextUnmarshaler will use that interface instead.

type Config

type Config struct {
	Host            string
	Port            int
	Deployment      string
	Debug           bool
	DisableMetric   bool
	DisableTrace    bool
	DisableSentinel bool
	CertFile        string
	PrivateFile     string
	EnableTLS       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, error)

Build create server instance, then initialize it with necessary interceptor

func (*Config) MustBuild added in v0.3.1

func (config *Config) MustBuild() *Server

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 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 ProtoBinder added in v0.10.2

type ProtoBinder struct{}

ProtoBinder is the default implementation of the Binder interface.

func (*ProtoBinder) Bind added in v0.10.2

func (b *ProtoBinder) Bind(i interface{}, c echo.Context) (err error)

Bind implements the `Binder#Bind` function. Binding is done in following order: 1) path params; 2) query params; 3) request body. Each step COULD override previous step binded values. For single source binding use their own methods BindBody, BindQueryParams, BindPathParams.

func (*ProtoBinder) BindBody added in v0.10.2

func (b *ProtoBinder) BindBody(c echo.Context, i interface{}) (err error)

BindBody binds request body contents to bindable object NB: then binding forms take note that this implementation uses standard library form parsing which parses form data from BOTH URL and BODY if content type is not echo.MIMEMultipartForm See non-echo.MIMEMultipartForm: https://golang.org/pkg/net/http/#Request.ParseForm See echo.MIMEMultipartForm: https://golang.org/pkg/net/http/#Request.ParseMultipartForm

func (*ProtoBinder) BindHeaders added in v0.10.2

func (b *ProtoBinder) BindHeaders(c echo.Context, i interface{}) error

BindHeaders binds HTTP headers to a bindable object

func (*ProtoBinder) BindPathParams added in v0.10.2

func (b *ProtoBinder) BindPathParams(c echo.Context, i interface{}) error

BindPathParams binds path params to bindable object

func (*ProtoBinder) BindQueryParams added in v0.10.2

func (b *ProtoBinder) BindQueryParams(c echo.Context, i interface{}) error

BindQueryParams binds query params to bindable object

type Server

type Server struct {
	*echo.Echo
	// 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) Healthz added in v0.3.1

func (s *Server) Healthz() bool

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

Serve implements server.Server interface.

func (*Server) Stop

func (s *Server) Stop() error

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

Jump to

Keyboard shortcuts

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