Documentation
¶
Index ¶
- func EncodeResponse(rw http.ResponseWriter, statusCode int, data interface{}) error
- func HandleErrorResponse(w http.ResponseWriter, err error)
- type Handler
- type HandlerSpec
- type PullPieceTaskResponseContinueData
- type RegisterResponseData
- type ResultInfo
- func NewResultInfo(code int, msg string, data interface{}) ResultInfo
- func NewResultInfoWithCode(code int) ResultInfo
- func NewResultInfoWithCodeData(code int, data interface{}) ResultInfo
- func NewResultInfoWithCodeError(code int, err error) ResultInfo
- func NewResultInfoWithCodeMsg(code int, msg string) ResultInfo
- func NewResultInfoWithError(err error) ResultInfo
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeResponse ¶
func EncodeResponse(rw http.ResponseWriter, statusCode int, data interface{}) error
EncodeResponse encodes response in json.
func HandleErrorResponse ¶
func HandleErrorResponse(w http.ResponseWriter, err error)
HandleErrorResponse handles err from daemon side and constructs response for client side.
Types ¶
type HandlerSpec ¶
HandlerSpec is used to describe a HTTP API.
func NewHandlerSpec ¶
func NewHandlerSpec(method, path string, handler Handler) *HandlerSpec
NewHandlerSpec constructs a brand new HandlerSpec.
type PullPieceTaskResponseContinueData ¶ added in v0.4.0
type PullPieceTaskResponseContinueData struct {
Range string `json:"range"`
PieceNum int `json:"pieceNum"`
PieceSize int32 `json:"pieceSize"`
PieceMd5 string `json:"pieceMd5"`
Cid string `json:"cid"`
PeerIP string `json:"peerIp"`
PeerPort int `json:"peerPort"`
Path string `json:"path"`
DownLink int `json:"downLink"`
}
PullPieceTaskResponseContinueData is the data when successfully pulling piece task and the task is continuing.
type RegisterResponseData ¶ added in v0.4.0
type RegisterResponseData struct {
TaskID string `json:"taskId"`
FileLength int64 `json:"fileLength"`
PieceSize int32 `json:"pieceSize"`
}
RegisterResponseData is the data when registering supernode successfully.
type ResultInfo ¶ added in v0.4.0
type ResultInfo struct {
// contains filtered or unexported fields
}
ResultInfo identify a struct that will returned to the client.
func NewResultInfo ¶ added in v0.4.0
func NewResultInfo(code int, msg string, data interface{}) ResultInfo
NewResultInfo returns a new ResultInfo.
func NewResultInfoWithCode ¶ added in v0.4.0
func NewResultInfoWithCode(code int) ResultInfo
NewResultInfoWithCode returns a new ResultInfo with code and it will get the default msg corresponding to the code as the value of ResultInfo.msg.
func NewResultInfoWithCodeData ¶ added in v0.4.0
func NewResultInfoWithCodeData(code int, data interface{}) ResultInfo
NewResultInfoWithCodeData returns a new ResultInfo with code and specified data.
func NewResultInfoWithCodeError ¶ added in v0.4.0
func NewResultInfoWithCodeError(code int, err error) ResultInfo
NewResultInfoWithCodeError returns a new ResultInfo with code and error. And it will get the err.Error() as the value of ResultInfo.msg.
func NewResultInfoWithCodeMsg ¶ added in v0.4.0
func NewResultInfoWithCodeMsg(code int, msg string) ResultInfo
NewResultInfoWithCodeMsg returns a new ResultInfo with code and specified msg.
func NewResultInfoWithError ¶ added in v0.4.0
func NewResultInfoWithError(err error) ResultInfo
NewResultInfoWithError returns a new ResultInfo with error only. And it will fill the result code according to the type of error.
func (ResultInfo) Error ¶ added in v0.4.0
func (r ResultInfo) Error() string
func (ResultInfo) SuccessCode ¶ added in v0.4.0
func (r ResultInfo) SuccessCode() bool
SuccessCode return whether the code equals SuccessCode.