restserver

package
v0.0.0-...-4311a38 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewDefaultClient

func NewDefaultClient(serverName string, endpoint string, opts ...ClientOption) *Client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, body interface{}) (int, []byte, error)

func (*Client) DeleteWithResult

func (c *Client) DeleteWithResult(ctx context.Context, path string, body interface{}, result interface{}) (int, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (int, []byte, error)

func (*Client) GetWithResult

func (c *Client) GetWithResult(ctx context.Context, path string, result interface{}) (int, error)

func (*Client) NextAddress

func (c *Client) NextAddress(ctx context.Context) (string, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body interface{}) (int, []byte, error)

func (*Client) PostWithResult

func (c *Client) PostWithResult(ctx context.Context, path string, body interface{}, result interface{}) (int, error)

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body interface{}) (int, []byte, error)

func (*Client) PutWithResult

func (c *Client) PutWithResult(ctx context.Context, path string, body interface{}, result interface{}) (int, error)

type ClientOption

type ClientOption func(c *Client)

func WithClientBalancer

func WithClientBalancer(b registry.Balancer) ClientOption

WithClientBalancer 设置负载均衡

func WithClientDiscovery

func WithClientDiscovery(d registry.Discovery) ClientOption

WithClientDiscovery 设置服务发现

func WithClientResolver

func WithClientResolver(r registry.Resolver) ClientOption

WithClientResolver 设置服务解析

func WithRestyClientFunc

func WithRestyClientFunc(f func() *resty.Client) ClientOption

WithRestyClientFunc 设置获取resty的client的函数

type Server

type Server struct {
	*gin.Engine
	// contains filtered or unexported fields
}

Server wrapper for gin.Engine

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

func (*Server) RegistryWebsocket

func (s *Server) RegistryWebsocket(relativePath string)

func (*Server) SocketIoServer

func (s *Server) SocketIoServer() *socketio.Server

func (*Server) Start

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

Start rest server

func (*Server) Stop

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

func (*Server) Translator

func (s *Server) Translator() ut.Translator

type ServerOption

type ServerOption func(*Server)

func WithAddress

func WithAddress(addr string) ServerOption

func WithClientEnableTracing

func WithClientEnableTracing(enableTracing bool) ServerOption

WithClientEnableTracing 设置是否开启链路追踪

func WithDebugMode

func WithDebugMode() ServerOption

func WithDefaultHealthCheck

func WithDefaultHealthCheck(enable bool) ServerOption

func WithEnTransNames

func WithEnTransNames() ServerOption

func WithEnableMetrics

func WithEnableMetrics(enable bool) ServerOption

func WithEnableProfiling

func WithEnableProfiling(enable bool) ServerOption

func WithEnableSocketIoServer

func WithEnableSocketIoServer(enableSocketIoServer bool) ServerOption

func WithMiddlewares

func WithMiddlewares(middlewares ...gin.HandlerFunc) ServerOption

func WithReleaseMode

func WithReleaseMode() ServerOption

func WithSocketIoServer

func WithSocketIoServer(socketIoServer *socketio.Server) ServerOption

func WithTLSConfig

func WithTLSConfig(certFile, keyFile string) ServerOption

WithTLSConfig with TLS config.

func WithTestMode

func WithTestMode() ServerOption

func WithTransName

func WithTransName(transName string) ServerOption

func WithZhTransNames

func WithZhTransNames() ServerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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