gin

package module
v0.0.0-...-f56a457 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiHandlerWrap

func ApiHandlerWrap(ctx *gin.Context, req interface{}, handlerFn apiHandlerFunc)

ApiHandlerWrap 路由自动校验入参 + 格式化返回值

Types

type Option

type Option func(*Options)

func Client

func Client(c client.Client) Option

Client to be used for service

func Server

func Server(s server.Server) Option

Server to be used for service

type Options

type Options struct {
	Server server.Server
	Client client.Client

	// Before and After funcs
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context

	Signal bool
}

Options for micro service

type ResponseData

type ResponseData struct {
	Code    int64
	Message string
	Data    interface{}
}

data part:

type Service

type Service interface {
	// The service name
	Name() string
	// Init initialises options
	Init(...Option)
	// Options returns the current options
	Options() Options
	// Client is used to call services
	Client() client.Client
	// Server is for handling requests and events
	Server() server.Server
	// Run the service
	Run() error
	// The service implementation
	String() string
}

Service is an interface that wraps the lower level libraries within go-micro. Its a convenience method for building and initialising services.

func NewService

func NewService(opts ...Option) Service

NewService creates and returns a new Service based on the packages within.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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