http

package
v0.0.0-...-9dac4f2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: BSD-2-Clause, MIT Imports: 17 Imported by: 0

Documentation

Overview

Package http RPC

Index

Constants

View Source
const NewlineTag = "<\\br>"

NewlineTag 换行符

View Source
const (
	// URL 服务地址
	URL = "https://127.0.0.1"
)

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(ctx *gin.Context, err error)

BadRequest 参数异常

func Fail

func Fail(ctx *gin.Context, err error)

Fail 失败

func New

func New(
	conf *Config,
	log log.Logger,
	flag bool,
	handler http.Handler,
) transport.Server

New 注册HTTP

func Success

func Success(ctx *gin.Context, data interface{})

Success 成功

Types

type Base

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

Base RPC基础

func InitBase

func InitBase(o ...Option) *Base

InitBase 初始化

func (*Base) Delete

func (b *Base) Delete(ctx context.Context, url string, param interface{}, data interface{}, op ...uh.Option) (err error)

Delete DELETE

func (*Base) Get

func (b *Base) Get(ctx context.Context, url string, param interface{}, data interface{}, op ...uh.Option) (err error)

Get GET

func (*Base) Post

func (b *Base) Post(ctx context.Context, url string, param interface{}, data interface{}, op ...uh.Option) (err error)

Post POST

func (*Base) Put

func (b *Base) Put(ctx context.Context, url string, param interface{}, data interface{}, op ...uh.Option) (err error)

Put PUT

func (*Base) Timeout

func (b *Base) Timeout() time.Duration

Timeout Timeout

func (*Base) Url

func (b *Base) Url() string

Url URL

type BaseRequest

type BaseRequest struct {
	// 页, 默认值 1
	PageNum int32 `form:"pageNum,default=1" json:"pageNum,default=1" default:"1"`
	// 页码,默认值 30
	PageSize int32 `form:"pageSize,default=30" json:"pageSize,default=30" default:"30"`
	// 排序字段
	SortField string `form:"sortField,default=id" json:"sortField,default=id" default:"id"`
	// 排序的方式,asc/desc
	SortOrder string `form:"sortOrder,default=asc" json:"sortOrder,default=asc" default:"asc"`
	// 排除Total
	ExclusiveTotal bool `json:"exclusiveTotal" example:"false"`
	// 排除List
	ExclusiveList bool `json:"exclusiveList" example:"false"`
	// Search 搜索条件
	Search []Search `form:"search" json:"search"`
}

type Config

type Config struct {
	Network string `json:"network,omitempty"`
	Addr    string `json:"addr,omitempty"`
	Timeout int32  `json:"timeout,omitempty"`
	// 模式 release/debug
	Model string `json:"model,omitempty"`
	// 开启swag
	EnableSwag bool `json:"enable_swag,omitempty"`
	// 开启pprof
	EnablePprof bool `json:"enable_pprof,omitempty"`
}

Config 配置

func (*Config) GetAddr

func (x *Config) GetAddr() string

func (*Config) GetEnablePprof

func (x *Config) GetEnablePprof() bool

func (*Config) GetEnableSwag

func (x *Config) GetEnableSwag() bool

func (*Config) GetModel

func (x *Config) GetModel() string

func (*Config) GetNetwork

func (x *Config) GetNetwork() string

func (*Config) GetTimeout

func (x *Config) GetTimeout() int32

type ExtendAttrsEntity

type ExtendAttrsEntity struct {
	ExtendAttrs map[string]interface{} `json:"extendAttrs" binding:"omitempty"`
}

ExtendAttrsEntity 扩展属性

type ExtendAttrsParam

type ExtendAttrsParam struct {
	ExtendAttrs map[string]interface{} `json:"extendAttrs" binding:"omitempty"`
}

ExtendAttrsParam 扩展属性

type ListResponse

type ListResponse struct {
	// 数据
	List interface{} `json:"list"`
}

ListResponse 列表返回结构

type Option

type Option func(o *options)

Option 可选项目

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 指定超时时间

func WithURL

func WithURL(url string) Option

WithURL 指定URL

type PageResponse

type PageResponse struct {
	// 数据
	List interface{} `json:"list"`
	// 页码
	PageNum int32 `json:"pageNum"`
	// 每页数量
	PageSize int32 `json:"pageSize"`
	// 总数
	Total int32 `json:"total"`
}

PageResponse 列表返回结构

type Response

type Response struct {
	// 错误码
	Code string `json:"code"`
	// 提示信息
	Msg string `json:"msg"`
	// 提示详情
	Detail interface{} `json:"detail"`
	// 数据
	Data interface{} `json:"data"`
}

Response 返回结构

type Search struct {
	// Option 搜索选项 equal/like
	Option string `json:"option" binding:"required"`
	// Key 搜索键 多个参数逗号隔开表示或,比如a,b,c 搜索 a or b or c
	Key string `json:"key" binding:"required"`
	// Value 搜索值
	Value interface{} `json:"value" binding:"required"`
}

Search 搜索关键字

Jump to

Keyboard shortcuts

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