restful

package
v0.0.0-...-1ae3dfb Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSucceed      = ErrCodeMsg{0, "ok"}
	ErrInvalidParam = ErrCodeMsg{100, "invalid parameter"}
	ErrServerInner  = ErrCodeMsg{101, "server inner error"}
	ErrLoginFailed  = ErrCodeMsg{102, "login failed, please retry"}
	ErrLoginNeeded  = ErrCodeMsg{103, "login first"}

	ErrInvalidBranch = ErrCodeMsg{200, "branch unavailable"}
	ErrExistOnLocal  = ErrCodeMsg{201, "branch exist in symbol store"}
	ErrUnknownBranch = ErrCodeMsg{202, "unknown branch"}
	ErrUnauthorized  = ErrCodeMsg{203, "unauthorized operation"}
)

Functions

func HttpGet

func HttpGet(uri string, fnCallback func(*http.Request)) (*bytes.Buffer, error)

HttpGet wrap of http.Get

func HttpPost

func HttpPost(uri string, body io.Reader, fnCallback func(*http.Request)) (*bytes.Buffer, error)

HttpPost wrap of http.Post

Types

type BranchList

type BranchList struct {
	Total   int              `json:"total"`
	Branchs []*symbol.Branch `json:"branchs"`
}

BranchList return branch list of current symbol store

type BuildList

type BuildList struct {
	Branch string          `json:"branchName"`
	Total  int             `json:"total"`
	Builds []*symbol.Build `json:"builds"`
}

type ErrCodeMsg

type ErrCodeMsg struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrCodeMsg is predefined error code and error message

type Message

type Message struct {
	Status int    `json:"status,omitempty"`
	Branch string `json:"branch,omitempty"`
	Build  string `json:"build,omitempty"`
	Date   string `json:"date,omitempty"`
}

type RestResponse

type RestResponse struct {
	ErrCodeMsg
	Data interface{} `json:"data"`
}

RestResponse is the basic struct used to wrap data back to client in json format.

func (*RestResponse) ToJSON

func (r *RestResponse) ToJSON() string

ToJSON encoding to json string

func (*RestResponse) WriteJSON

func (r *RestResponse) WriteJSON(w http.ResponseWriter) error

WriteJSON write json reponse to client

type SymbolList

type SymbolList struct {
	Branch  string           `json:"branchName"`
	Build   string           `json:"buildID"`
	Total   int              `json:"total"`
	Symbols []*symbol.Symbol `json:"symbols"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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