api

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr              string        `json:"addr"`
	Engine            string        `json:"engine"`
	Status            engine.Status `json:"status"`
	ReadTimeout       uint          `json:"read_timeout"`
	WriteTimeout      uint          `json:"write_timeout"`
	ReadHeaderTimeout uint          `json:"read_header_timeout"`
	MaxHeaderBytes    uint          `json:"max_header_bytes"`
}

type Option

type Option func(*options)

Option 参数设置类型

func Log added in v0.1.13

func Log(opts ...log.ServerOption) Option

Log 设置日志配置

func WithAddr added in v0.5.2

func WithAddr(addr string) Option

WithAddr 设置服务地址

func WithConfig

func WithConfig(config config.Config) Option

WithStartedHook 设置启动回调函数

func WithDecodeRequestFunc added in v0.5.1

func WithDecodeRequestFunc(decReq engine.DecodeRequestFunc) Option

WithDecodeRequestFunc 解析入参

func WithEncodeErrorFunc added in v0.5.1

func WithEncodeErrorFunc(encErr engine.EncodeErrorFunc) Option

WithEncodeErrorFunc 编码错误

func WithEncodeResponseFunc added in v0.5.1

func WithEncodeResponseFunc(encResp engine.EncodeResponseFunc) Option

WithEncodeResponseFunc 编码响应

func WithEndHook

func WithEndHook(f engine.Hook) Option

func WithEngine added in v0.5.2

func WithEngine(engine string) Option

WithEngine 设置服务引擎(gin)

func WithMaxHeaderBytes added in v0.5.2

func WithMaxHeaderBytes(maxHeaderBytes uint) Option

WithMaxHeaderBytes 最大头部大小(http.DefaultMaxHeaderBytes untyped int = 1 << 20 )

func WithReadHeaderTimeout added in v0.5.2

func WithReadHeaderTimeout(readHeaderTimeout uint) Option

ReadHeaderTimeout 写入超时时间

func WithReadTimeout added in v0.5.2

func WithReadTimeout(readTimeout uint) Option

WithReadTimeout 读取超时时间

func WithServiceName added in v0.1.1

func WithServiceName(serviceName string) Option

WithServiceName 设置服务名称

func WithStartedHook

func WithStartedHook(f engine.Hook) Option

WithStartedHook 设置启动回调函数

func WithWriteTimeout added in v0.5.2

func WithWriteTimeout(writeTimeout uint) Option

WithWriteTimeout 写入超时时间

type Server

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

func New

func New(name string, opts ...Option) *Server

New 实例化

func (*Server) Attempt

func (e *Server) Attempt() bool

Attempt 判断是否可以启动

func (*Server) Config

func (e *Server) Config(cfg config.Config)

func (*Server) Endpoint

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

http://127.0.0.1:8000

func (*Server) Group

func (e *Server) Group(group string, middlewares ...middleware.Middleware) *engine.RouterGroup

func (*Server) Handle

func (e *Server) Handle(path string, obj interface{}, methods ...engine.Method)

func (*Server) Name

func (e *Server) Name() string

func (*Server) Options

func (e *Server) Options(opts ...Option)

Options 设置参数

func (*Server) ServiceName added in v0.1.1

func (s *Server) ServiceName() string

ServiceName 服务名称

func (*Server) Start

func (e *Server) Start(ctx context.Context) (err error)

Start 开始

func (*Server) Static

func (e *Server) Static(path, root string)

func (*Server) StaticFile

func (e *Server) StaticFile(path, filepath string)

func (*Server) Stop

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

Shutdown 停止

func (*Server) Type

func (e *Server) Type() string

func (*Server) Use

func (e *Server) Use(middlewares ...middleware.Middleware)

type Static

type Static struct {
	RouterPath string
	FilePath   string
	IsFile     bool
}

Jump to

Keyboard shortcuts

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