httpd

package
v0.0.0-...-d31617f Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebApiPort       = 80
	HttpReadTimeout  = 30
	HttpWriteTimeout = 60
)

Variables

This section is empty.

Functions

func CustomStatus

func CustomStatus(c *gin.Context, status, message string, data interface{})

返回自定义 status, http 200

func Error

func Error(c *gin.Context, err error)

返回失败 http 400

func NewHttpServer

func NewHttpServer(appName string, port int, router func(*gin.Engine), stats func(*gin.Context, interface{}) error,
	throttle func() gin.HandlerFunc) server

* 创建HTTP API服务 * * param appName 服务命名,便于输出日志 * param port 侦听端口 * param router API路由注册回调函数 * param stats 预留 * param throttle 限流回调函数

func Ok

func Ok(c *gin.Context, data interface{})

返回成功 http 200

Types

type Pagination

type Pagination struct {
	Current  int   `json:"current"`
	PageSize int   `json:"pageSize"`
	Total    int64 `json:"total,omitempty"`
}

type Paging

type Paging struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
}

type PagingResult

type PagingResult struct {
	List       interface{} `json:"list,omitempty"`
	Pagination Pagination  `json:"pagination,omitempty"`
}

分页结构体

func NewPagingResult

func NewPagingResult(current, pagesize int, total int64, list interface{}) PagingResult

分页数据结构体

type Response

type Response struct {
	Timestamp time.Time   `json:"timestamp"`         //时间戳
	Status    string      `json:"status,omitempty"`  //接口请求的返回状态,success 或者 error
	Message   string      `json:"message,omitempty"` //返回消息
	Data      interface{} `json:"data,omitempty"`    //具体数据
}

统一返回结构

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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