rainbond: github.com/goodrain/rainbond/util/http Index | Files

package http

import "github.com/goodrain/rainbond/util/http"

Index

Package Files

api.go

func Return Uses

func Return(r *http.Request, w http.ResponseWriter, code int, reb ResponseBody)

Return 自定义

func ReturnError Uses

func ReturnError(r *http.Request, w http.ResponseWriter, code int, msg string)

ReturnError 返回错误信息

func ReturnList Uses

func ReturnList(r *http.Request, w http.ResponseWriter, listAllNumber, page int, datas ...interface{})

ReturnList 返回列表

func ReturnNoFomart Uses

func ReturnNoFomart(r *http.Request, w http.ResponseWriter, code int, reb interface{})

ReturnNoFomart http return no format result

func ReturnSuccess Uses

func ReturnSuccess(r *http.Request, w http.ResponseWriter, datas interface{})

ReturnSuccess 成功返回

func ReturnValidationError Uses

func ReturnValidationError(r *http.Request, w http.ResponseWriter, err url.Values)

ReturnValidationError 参数错误返回

func ValidatorMapRequest Uses

func ValidatorMapRequest(r *http.Request, rule govalidator.MapData, message govalidator.MapData) (map[string]interface{}, url.Values)

ValidatorMapRequest 验证请求数据从map

func ValidatorRequestMapAndErrorResponse Uses

func ValidatorRequestMapAndErrorResponse(r *http.Request, w http.ResponseWriter, rule govalidator.MapData, messgae govalidator.MapData) (map[string]interface{}, bool)

ValidatorRequestMapAndErrorResponse 验证并格式化请求数据为对象 retrun true 继续执行 return false 参数错误,终止

func ValidatorRequestStructAndErrorResponse Uses

func ValidatorRequestStructAndErrorResponse(r *http.Request, w http.ResponseWriter, data interface{}, message govalidator.MapData) bool

ValidatorRequestStructAndErrorResponse 验证并格式化请求数据为对象 retrun true 继续执行 return false 参数错误,终止

func ValidatorStructRequest Uses

func ValidatorStructRequest(r *http.Request, data interface{}, message govalidator.MapData) url.Values

ValidatorStructRequest 验证请求数据 data 传入指针

type ResponseBody Uses

type ResponseBody struct {
    ValidationError url.Values  `json:"validation_error,omitempty"`
    Msg             string      `json:"msg,omitempty"`
    Bean            interface{} `json:"bean,omitempty"`
    List            interface{} `json:"list,omitempty"`
    //数据集总数
    ListAllNumber int `json:"number,omitempty"`
    //当前页码数
    Page int `json:"page,omitempty"`
}

ResponseBody api返回数据格式

func ParseResponseBody Uses

func ParseResponseBody(red io.ReadCloser, dataType string) (re ResponseBody, err error)

ParseResponseBody 解析成ResponseBody

Package http imports 9 packages (graph) and is imported by 18 packages. Updated 2019-04-21. Refresh now. Tools for package owners.