Documentation ¶
Index ¶
- Constants
- func CheckCrossOrigin(w http.ResponseWriter, r *http.Request) bool
- func ConfigRateLimits()
- func Done()
- func GetRootContext() context.Context
- func HandleShutdown(server *http.Server)
- func InitSDK(clientJSON string) error
- func InvalidRequest(msg string) error
- func JSONString(json map[string]interface{}, field string, required bool) (string, error)
- func MethodError(endpoint, method string) error
- func PrintError(v ...interface{})
- func Respond(w http.ResponseWriter, data interface{}, err error)
- func SetupCORSResponse(w http.ResponseWriter, r *http.Request)
- func SetupRootContext(ctx context.Context)
- func SplitArgs(args string) []string
- func ValidateClientDetails(allocation, clientJSON string) error
- func WithUserRateLimit(h http.Handler) http.Handler
- type Error
- type JSONReqResponderF
- type JSONResponderF
- type ReqRespHandlerf
- func ToFileResponse(handler JSONResponderF) ReqRespHandlerf
- func ToJSONReqResponse(handler JSONReqResponderF) ReqRespHandlerf
- func ToJSONResponse(handler JSONResponderF) ReqRespHandlerf
- func ToStreamResponse(handler StreamResponderF) ReqRespHandlerf
- func UserRateLimit(handler ReqRespHandlerf) ReqRespHandlerf
- type StatusBar
- func (s *StatusBar) CommitMetaCompleted(request, response string, err error)
- func (s *StatusBar) Completed(allocationID, filePath string, filename string, mimetype string, size int, ...)
- func (s *StatusBar) Error(allocationID string, filePath string, op int, err error)
- func (s *StatusBar) InProgress(allocationID, filePath string, op int, completedBytes int, bytes []byte)
- func (s *StatusBar) RepairCompleted(filesRepaired int)
- func (s *StatusBar) Started(allocationID, filePath string, op int, totalBytes int)
- type StreamResponderF
Constants ¶
const AppErrorHeader = "X-App-Error-Code"
AppErrorHeader - a http response header to send an application error code
Variables ¶
This section is empty.
Functions ¶
func CheckCrossOrigin ¶
func CheckCrossOrigin(w http.ResponseWriter, r *http.Request) bool
func GetRootContext ¶
GetRootContext - get the root context for the server * This will be used to control shutting down the server but cleanup all the workers
func HandleShutdown ¶
HandleShutdown - handles various shutdown signals
func InvalidRequest ¶
InvalidRequest - create error messages that are needed when validating request input
func JSONString ¶
JSONString - given a json map and a field return the string typed value * required indicates whether to throw an error if the field is not found
func MethodError ¶
func Respond ¶
func Respond(w http.ResponseWriter, data interface{}, err error)
Respond - respond either data or error as a response
func SetupCORSResponse ¶
func SetupCORSResponse(w http.ResponseWriter, r *http.Request)
func SetupRootContext ¶
SetupRootContext - sets up the root context that can be used to shutdown the node
func ValidateClientDetails ¶
Types ¶
type JSONReqResponderF ¶
JSONReqResponderF - a handler that takes a JSON request and responds with a json response * Useful for GET operation where the input is coming via url parameters
type JSONResponderF ¶
JSONResponderF - a handler that takes standard request (non-json) and responds with a json response * Useful for POST opertaion where the input is posted as json with * Content-type: application/json * header
type ReqRespHandlerf ¶
type ReqRespHandlerf func(w http.ResponseWriter, r *http.Request)
ReqRespHandlerf - a type for the default hanlder signature
func ToFileResponse ¶
func ToFileResponse(handler JSONResponderF) ReqRespHandlerf
ToFileResponse to give file as response
func ToJSONReqResponse ¶
func ToJSONReqResponse(handler JSONReqResponderF) ReqRespHandlerf
ToJSONReqResponse - An adapter that takes a handler of the form * func AHandler(json map[string]interface{}) (interface{}, error) * which takes a parsed json map from the request, processes and returns an object or an error * and converts into a standard request/response handler
func ToJSONResponse ¶
func ToJSONResponse(handler JSONResponderF) ReqRespHandlerf
ToJSONResponse - An adapter that takes a handler of the form * func AHandler(r *http.Request) (interface{}, error) * which takes a request object, processes and returns an object or an error * and converts into a standard request/response handler
func ToStreamResponse ¶
func ToStreamResponse(handler StreamResponderF) ReqRespHandlerf
ToStreamResponse to give stream as response
func UserRateLimit ¶
func UserRateLimit(handler ReqRespHandlerf) ReqRespHandlerf
UserRateLimit - rate limiting for end user handlers
type StatusBar ¶
type StatusBar struct { Wait *sync.WaitGroup Success bool Err error // contains filtered or unexported fields }
StatusBar is to check status of any operation
func (*StatusBar) CommitMetaCompleted ¶
CommitMetaCompleted when commit meta completes
func (*StatusBar) Completed ¶
func (s *StatusBar) Completed(allocationID, filePath string, filename string, mimetype string, size int, op int)
Completed for statusBar
func (*StatusBar) InProgress ¶
func (s *StatusBar) InProgress(allocationID, filePath string, op int, completedBytes int, bytes []byte)
InProgress for statusBar
func (*StatusBar) RepairCompleted ¶
RepairCompleted when repair is completed
type StreamResponderF ¶
type StreamResponderF func(w http.ResponseWriter, r *http.Request) (interface{}, error)