api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: MIT Imports: 16 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"`
	Status            server.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 WithConfig

func WithConfig(config config.Config) Option

WithStartedHook 设置启动回调函数

func WithEndHook

func WithEndHook(f server.Hook) Option

func WithServiceName added in v0.1.1

func WithServiceName(serviceName string) Option

WithServiceName 设置服务名称

func WithStartedHook

func WithStartedHook(f server.Hook) Option

WithStartedHook 设置启动回调函数

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) *server.RouterGroup

func (*Server) Handle

func (e *Server) Handle(path string, obj interface{}, methods ...server.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) 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 Setting

type Setting struct {
	Config      Config              `json:"config" yaml:"config"`
	Middlewares []middleware.Config `json:"middlewares"  yaml:"middlewares"`
	Header      server.Header       `json:"header"  yaml:"header"`
}

```

"api":{
	"config":{"addr":":8080","status":"start/stop","read_timeout":10,"write_timeout":10,"read_header_timeout":10,"max_header_bytes":65525},
	"middlewares":[
	{
		"auth":{
			"proto":"jwt",
			"jwt":{},
			"exclude":["/**"]
		}
	},{}],
	"header":{},
}

```

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