Documentation ¶
Index ¶
- Variables
- func APIVersion(ctx context.Context) string
- func OcsV1StatusCodes(meta Meta) int
- func OcsV2StatusCodes(meta Meta) int
- func VersionCtx(next http.Handler) http.Handler
- func WriteOCSData(w http.ResponseWriter, r *http.Request, m Meta, d interface{}, err error)
- func WriteOCSError(w http.ResponseWriter, r *http.Request, c int, m string, err error)
- func WriteOCSResponse(w http.ResponseWriter, r *http.Request, res Response, err error)
- func WriteOCSSuccess(w http.ResponseWriter, r *http.Request, d interface{})
- type Meta
- type Payload
- type Response
Constants ¶
This section is empty.
Variables ¶
var MessageGroupNotFound = "The requested group could not be found"
MessageGroupNotFound is used when a group can not be found
var MessageLockedForSharing = "The file is locked until the file is in use by at least one user"
MessageLockedForSharing is used when a user tries to create a new share until the file is in use by at least one user
var MessagePathNotFound = "Wrong path, file/folder doesn't exist"
MessagePathNotFound is used when a file or folder can not be found
MessageShareExists is used when a user tries to create a new share for the same user
var MessageUserNotFound = "The requested user could not be found"
MessageUserNotFound is used when a user can not be found
var MetaBadRequest = Meta{Status: "error", StatusCode: 400, Message: "Bad Request"}
MetaBadRequest is used for unknown errors
var MetaFailure = Meta{Status: "", StatusCode: 101, Message: "Failure"}
MetaFailure is a failure response with code 101
var MetaForbidden = Meta{Status: "", StatusCode: 104, Message: "Forbidden"}
MetaForbidden is an error response with code 104
var MetaInvalidInput = Meta{Status: "", StatusCode: 102, Message: "Invalid Input"}
MetaInvalidInput is an error response with code 102
var MetaLocked = Meta{Status: "failure", StatusCode: 423, Message: "The file is locked"}
MetaLocked is returned when trying to share not existing resources
var MetaNotFound = Meta{Status: "error", StatusCode: 998, Message: "Not Found"}
MetaNotFound is returned when trying to access not existing resources
var MetaOK = Meta{Status: "ok", StatusCode: 100, Message: "OK"}
MetaOK is the default ok response
var MetaPathNotFound = Meta{Status: "failure", StatusCode: 404, Message: MessagePathNotFound}
MetaPathNotFound is returned when trying to share not existing resources
var MetaServerError = Meta{Status: "error", StatusCode: 996, Message: "Server Error"}
MetaServerError is returned on server errors
MetaUnauthorized is returned on unauthorized requests
var MetaUnknownError = Meta{Status: "error", StatusCode: 999, Message: "Unknown Error"}
MetaUnknownError is used for unknown errors
Functions ¶
func APIVersion ¶
APIVersion retrieves the api version from the context.
func OcsV1StatusCodes ¶
OcsV1StatusCodes returns the http status codes for the OCS API v1.
func OcsV2StatusCodes ¶
OcsV2StatusCodes maps the OCS codes to http status codes for the ocs API v2.
func VersionCtx ¶
WithAPIVersion puts the api version in the context.
func WriteOCSData ¶
WriteOCSData handles writing ocs data in json and xml
func WriteOCSError ¶
WriteOCSError handles writing error ocs responses
func WriteOCSResponse ¶
WriteOCSResponse handles writing ocs responses in json and xml
func WriteOCSSuccess ¶
func WriteOCSSuccess(w http.ResponseWriter, r *http.Request, d interface{})
WriteOCSSuccess handles writing successful ocs response data
Types ¶
type Meta ¶
type Meta struct { Status string `json:"status" xml:"status"` StatusCode int `json:"statuscode" xml:"statuscode"` Message string `json:"message" xml:"message"` TotalItems string `json:"totalitems,omitempty" xml:"totalitems,omitempty"` ItemsPerPage string `json:"itemsperpage,omitempty" xml:"itemsperpage,omitempty"` }
Meta holds response metadata
type Payload ¶
type Payload struct { XMLName struct{} `json:"-" xml:"ocs"` Meta Meta `json:"meta" xml:"meta"` Data interface{} `json:"data,omitempty" xml:"data,omitempty"` }
Payload combines response metadata and data
func (Payload) MarshalXML ¶
MarshalXML handles ocs specific wrapping of array members in 'element' tags for the data