magicapi

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiHook

type ApiHook interface {
	RecordFunc(record RecordData) error //记录api
}

type Config

type Config struct {
	MagicUrl string //magic-api url
	IsDebug  bool   //是否开启调试信息
}

type Context

type Context struct {
	Config Config

	Logger  *zap.Logger
	ApiHook ApiHook
	// contains filtered or unexported fields
}

func NewContext

func NewContext(config Config, logger *zap.Logger, apiHook ApiHook) *Context

type MagicSdk

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

func NewMagicSdk

func NewMagicSdk(ctx *Context) *MagicSdk

func (*MagicSdk) NewMagicRequest

func (s *MagicSdk) NewMagicRequest(uri string, body any, obj any) (err error)

NewMagicRequest 创建magic请求

type RecordData

type RecordData struct {
	Url      string `json:"url" gorm:"column:url;type:text;"`
	Method   string `json:"method"` //请求方式
	Body     string `json:"body" gorm:"column:body;type:longtext;"`
	Response string `json:"response" gorm:"column:response;type:longtext;"`
	Error    string `json:"error" gorm:"column:error;type:text;"`
	Status   int    `json:"status" gorm:"column:status;"` //http code
	Duration int64  `json:"duration"`                     //请求时长 ms
}

Jump to

Keyboard shortcuts

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