Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2018 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

View Source
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"
)

Functions

This section is empty.

Types

type BaseResponse added in v0.2.0

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 added in v0.2.0

func (r *BaseResponse) GetCode() int

GetCode get error code

func (*BaseResponse) GetData added in v0.2.0

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

GetData get data

func (*BaseResponse) GetMessage added in v0.2.0

func (r *BaseResponse) GetMessage() string

GetMessage get message

func (*BaseResponse) SetCode added in v0.2.0

func (r *BaseResponse) SetCode(code int)

SetCode set error code

func (*BaseResponse) SetData added in v0.2.0

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

SetData the data will be serialized to json string

func (*BaseResponse) SetMessage added in v0.2.0

func (r *BaseResponse) SetMessage(message string)

SetMessage set message

type RequestBody added in v0.2.0

type RequestBody struct{}

RequestBody the annotation RequestBody

type RequestForm added in v0.2.0

type RequestForm struct{}

RequestForm the annotation RequestForm

type RequestParams added in v0.2.0

type RequestParams struct{}

RequestParams the annotation RequestParams

type Response

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

Jump to

Keyboard shortcuts

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