hiboot: hidevops.io/hiboot/pkg/model Index | Files

package model

import "hidevops.io/hiboot/pkg/model"

Package model provides common request and response models.

// UserRequest is the request body
type UserRequest struct {
	model.RequestBody	// annotation RequestBody
	Username string		`validate:"required"`
	Password string 	`validate:"required"`
}

Index

Package Files

doc.go request.go response.go

Variables

var (
    // RequestTypeBody means it is RequestBody
    RequestTypeBody = "RequestBody"
    // RequestTypeParams means it is RequestParams
    RequestTypeParams = "RequestParams"
    // RequestTypeForm means it is RequestForm
    RequestTypeForm = "RequestForm"
    // Context means it is Context
    Context = "Context"
)

type BaseResponse Uses

type BaseResponse struct {
    Code    int         `json:"code"`
    Message string      `json:"message"`
    Data    interface{} `json:"data"`
}

BaseResponse is the implementation of rest controller's Response

func (*BaseResponse) GetCode Uses

func (r *BaseResponse) GetCode() int

GetCode get error code

func (*BaseResponse) GetData Uses

func (r *BaseResponse) GetData() interface{}

GetData get data

func (*BaseResponse) GetMessage Uses

func (r *BaseResponse) GetMessage() string

GetMessage get message

func (*BaseResponse) SetCode Uses

func (r *BaseResponse) SetCode(code int)

SetCode set error code

func (*BaseResponse) SetData Uses

func (r *BaseResponse) SetData(data interface{})

SetData the data will be serialized to json string

func (*BaseResponse) SetMessage Uses

func (r *BaseResponse) SetMessage(message string)

SetMessage set message

type RequestBody Uses

type RequestBody struct{}

RequestBody the annotation RequestBody

type RequestForm Uses

type RequestForm struct{}

RequestForm the annotation RequestForm

type RequestParams Uses

type RequestParams struct{}

RequestParams the annotation RequestParams

type Response Uses

type Response interface {
    // Set error code
    SetCode(code int)
    // Get error code
    GetCode() int
    // Set message
    SetMessage(message string)
    // Get message
    GetMessage() string
    // Set data, the data will be serialized to json string
    SetData(data interface{})
    // Get data
    GetData() interface{}
}

Response is the interface of rest controller's Response

Package model is imported by 7 packages. Updated 2019-05-20. Refresh now. Tools for package owners.