tus

package
v0.0.0-...-5a969d9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "tus"

ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.

Variables

View Source
var MethodNames = [5]string{"head", "patch", "options", "post", "delete"}

MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.

Functions

func MakeChecksumMismatch

func MakeChecksumMismatch(err error) *goa.ServiceError

MakeChecksumMismatch builds a goa.ServiceError from an error.

func MakeGone

func MakeGone(err error) *goa.ServiceError

MakeGone builds a goa.ServiceError from an error.

func MakeInternal

func MakeInternal(err error) *goa.ServiceError

MakeInternal builds a goa.ServiceError from an error.

func MakeInvalidChecksumAlgorithm

func MakeInvalidChecksumAlgorithm(err error) *goa.ServiceError

MakeInvalidChecksumAlgorithm builds a goa.ServiceError from an error.

func MakeInvalidContentType

func MakeInvalidContentType(err error) *goa.ServiceError

MakeInvalidContentType builds a goa.ServiceError from an error.

func MakeInvalidDeferLength

func MakeInvalidDeferLength(err error) *goa.ServiceError

MakeInvalidDeferLength builds a goa.ServiceError from an error.

func MakeInvalidOffset

func MakeInvalidOffset(err error) *goa.ServiceError

MakeInvalidOffset builds a goa.ServiceError from an error.

func MakeMaximumSizeExceeded

func MakeMaximumSizeExceeded(err error) *goa.ServiceError

MakeMaximumSizeExceeded builds a goa.ServiceError from an error.

func MakeMissingHeader

func MakeMissingHeader(err error) *goa.ServiceError

MakeMissingHeader builds a goa.ServiceError from an error.

func MakeNotFound

func MakeNotFound(err error) *goa.ServiceError

MakeNotFound builds a goa.ServiceError from an error.

func NewDeleteEndpoint

func NewDeleteEndpoint(s Service) goa.Endpoint

NewDeleteEndpoint returns an endpoint function that calls the method "delete" of service "tus".

func NewHeadEndpoint

func NewHeadEndpoint(s Service) goa.Endpoint

NewHeadEndpoint returns an endpoint function that calls the method "head" of service "tus".

func NewOptionsEndpoint

func NewOptionsEndpoint(s Service) goa.Endpoint

NewOptionsEndpoint returns an endpoint function that calls the method "options" of service "tus".

func NewPatchEndpoint

func NewPatchEndpoint(s Service) goa.Endpoint

NewPatchEndpoint returns an endpoint function that calls the method "patch" of service "tus".

func NewPostEndpoint

func NewPostEndpoint(s Service) goa.Endpoint

NewPostEndpoint returns an endpoint function that calls the method "post" of service "tus".

Types

type Client

type Client struct {
	HeadEndpoint    goa.Endpoint
	PatchEndpoint   goa.Endpoint
	OptionsEndpoint goa.Endpoint
	PostEndpoint    goa.Endpoint
	DeleteEndpoint  goa.Endpoint
}

Client is the "tus" service client.

func NewClient

func NewClient(head, patch, options, post, delete_ goa.Endpoint) *Client

NewClient initializes a "tus" service client given the endpoints.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, p *DeletePayload) (res *DeleteResult, err error)

Delete calls the "delete" endpoint of the "tus" service. Delete may return the following errors:

  • "NotFound" (type *goa.ServiceError): For all future requests to this URL, the Server SHOULD respond with the 404 Not Found or 410 Gone status.
  • "Gone" (type *goa.ServiceError): For all future requests to this URL, the Server SHOULD respond with the 404 Not Found or 410 Gone status.
  • "InvalidTusResumable" (type *ErrInvalidTUSResumable): If the version specified by the Client is not supported by the Server, it MUST respond with the 412 Precondition Failed status.
  • error: internal error

func (*Client) Head

func (c *Client) Head(ctx context.Context, p *HeadPayload) (res *HeadResult, err error)

Head calls the "head" endpoint of the "tus" service. Head may return the following errors:

  • "NotFound" (type *goa.ServiceError): If the resource is not found, the Server SHOULD return either the 404 Not Found, 410 Gone or 403 Forbidden status without the Upload-Offset header.
  • "Gone" (type *goa.ServiceError): If the resource is not found, the Server SHOULD return either the 404 Not Found, 410 Gone or 403 Forbidden status without the Upload-Offset header.
  • "InvalidTusResumable" (type *ErrInvalidTUSResumable): If the version specified by the Client is not supported by the Server, it MUST respond with the 412 Precondition Failed status.
  • error: internal error

func (*Client) Options

func (c *Client) Options(ctx context.Context) (res *OptionsResult, err error)

Options calls the "options" endpoint of the "tus" service. Options may return the following errors:

  • "InvalidTusResumable" (type *ErrInvalidTUSResumable): If the version specified by the Client is not supported by the Server, it MUST respond with the 412 Precondition Failed status.
  • error: internal error

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, p *PatchPayload, req io.ReadCloser) (res *PatchResult, err error)

Patch calls the "patch" endpoint of the "tus" service. Patch may return the following errors:

  • "InvalidContentType" (type *goa.ServiceError): All PATCH requests MUST use Content-Type: application/offset+octet-stream, otherwise the server SHOULD return a 415 Unsupported Media Type status.
  • "InvalidOffset" (type *goa.ServiceError): If the offsets do not match, the Server MUST respond with the 409 Conflict status without modifying the upload resource.
  • "NotFound" (type *goa.ServiceError): If a Client does attempt to resume an upload which has since been removed by the Server, the Server SHOULD respond with the404 Not Found or 410 Gone status.
  • "Gone" (type *goa.ServiceError): If a Client does attempt to resume an upload which has since been removed by the Server, the Server SHOULD respond with the404 Not Found or 410 Gone status.
  • "InvalidChecksumAlgorithm" (type *goa.ServiceError): The checksum algorithm is not supported by the server.
  • "ChecksumMismatch" (type *goa.ServiceError): The checksums mismatch.
  • "Internal" (type *goa.ServiceError): Internal error
  • "InvalidTusResumable" (type *ErrInvalidTUSResumable): If the version specified by the Client is not supported by the Server, it MUST respond with the 412 Precondition Failed status.
  • error: internal error

func (*Client) Post

func (c *Client) Post(ctx context.Context, p *PostPayload, req io.ReadCloser) (res *PostResult, err error)

Post calls the "post" endpoint of the "tus" service. Post may return the following errors:

  • "MissingHeader" (type *goa.ServiceError): The request MUST include one of the following headers: a) Upload-Length -or- b) Upload-Defer-Length: 1
  • "InvalidDeferLength" (type *goa.ServiceError): If the Upload-Defer-Length header contains any other value than 1 the server should return a 400 Bad Request status.
  • "MaximumSizeExceeded" (type *goa.ServiceError): If the length of the upload exceeds the maximum, which MAY be specified using the Tus-Max-Size header, the Server MUST respond with the 413 Request Entity Too Large status.
  • "InvalidChecksumAlgorithm" (type *goa.ServiceError): The checksum algorithm is not supported by the server.
  • "ChecksumMismatch" (type *goa.ServiceError): The checksums mismatch.
  • "InvalidTusResumable" (type *ErrInvalidTUSResumable): If the version specified by the Client is not supported by the Server, it MUST respond with the 412 Precondition Failed status.
  • error: internal error

type DeletePayload

type DeletePayload struct {
	// IDs are generated using Xid: https://github.com/rs/xid
	ID string
	// tusResumable represents a tus protocol version.
	TusResumable string
}

DeletePayload is the payload type of the tus service delete method.

type DeleteResult

type DeleteResult struct {
	// tusResumable represents a tus protocol version.
	TusResumable string
}

DeleteResult is the result type of the tus service delete method.

type Endpoints

type Endpoints struct {
	Head    goa.Endpoint
	Patch   goa.Endpoint
	Options goa.Endpoint
	Post    goa.Endpoint
	Delete  goa.Endpoint
}

Endpoints wraps the "tus" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "tus" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "tus" service endpoints.

type ErrInvalidTUSResumable

type ErrInvalidTUSResumable struct {
	// Comma separated list of supported versions.
	TusVersion string
}

ErrInvalidTUSResumable describes the error returned when a non-supported Tus-Resumable header is provided by the client.

func (*ErrInvalidTUSResumable) Error

func (e *ErrInvalidTUSResumable) Error() string

Error returns an error description.

func (*ErrInvalidTUSResumable) ErrorName deprecated

func (e *ErrInvalidTUSResumable) ErrorName() string

ErrorName returns "ErrInvalidTUSResumable".

Deprecated: Use GoaErrorName - https://github.com/goadesign/goa/issues/3105

func (*ErrInvalidTUSResumable) GoaErrorName

func (e *ErrInvalidTUSResumable) GoaErrorName() string

GoaErrorName returns "ErrInvalidTUSResumable".

type HeadPayload

type HeadPayload struct {
	// IDs are generated using Xid: https://github.com/rs/xid
	ID string
	// tusResumable represents a tus protocol version.
	TusResumable string
}

HeadPayload is the payload type of the tus service head method.

type HeadResult

type HeadResult struct {
	// tusResumable represents a tus protocol version.
	TusResumable string
	// uploadOffset represents a byte offset within a resource.
	UploadOffset int64
	// uploadLength represents the size of the entire upload in bytes.
	UploadLength *int64
	// The Upload-Defer-Length request and response header indicates that the size
	// of the upload is not known currently and will be transferred later.
	UploadDeferLength *int
	// The Client MAY supply the Upload-Metadata header to add additional metadata
	// to the upload creation request.
	UploadMetadata *string
}

HeadResult is the result type of the tus service head method.

type OptionsResult

type OptionsResult struct {
	// tusResumable represents a tus protocol version.
	TusResumable string
	// tusVersion is a comma separated list of protocol versions supported by the
	// server. This implementation only supports 1.0.0.
	TusVersion string
	// tusExtension is a comma separated list of extensions supported by the
	// server. This implementation supports the creation, creation-with-upload,
	// expiration, checksum and termination extensions
	TusExtension string
	// tusMaxSize represents the maximum allowed size of an entire upload in bytes.
	TusMaxSize *int64
	// A Client MAY include the Upload-Checksum header in a PATCH request. Once the
	// entire request has been received, the Server MUST verify the uploaded chunk
	// against the provided checksum using the specified algorithm.
	TusChecksumAlgorithm string
}

OptionsResult is the result type of the tus service options method.

type PatchPayload

type PatchPayload struct {
	// IDs are generated using Xid: https://github.com/rs/xid
	ID string
	// tusResumable represents a tus protocol version.
	TusResumable string
	// uploadOffset represents a byte offset within a resource.
	UploadOffset int64
	// A Client MAY include the Upload-Checksum header in a PATCH request. Once the
	// entire request has been received, the Server MUST verify the uploaded chunk
	// against the provided checksum using the specified algorithm.
	UploadChecksum *string
}

PatchPayload is the payload type of the tus service patch method.

type PatchRequestData

type PatchRequestData struct {
	// Payload is the method payload.
	Payload *PatchPayload
	// Body streams the HTTP request body.
	Body io.ReadCloser
}

PatchRequestData holds both the payload and the HTTP request body reader of the "patch" method.

type PatchResult

type PatchResult struct {
	// tusResumable represents a tus protocol version.
	TusResumable string
	// uploadOffset represents a byte offset within a resource.
	UploadOffset int64
	// The Upload-Expires response header indicates the time after which the
	// unfinished upload expires.
	UploadExpires *string
}

PatchResult is the result type of the tus service patch method.

type PostPayload

type PostPayload struct {
	// tusResumable represents a tus protocol version.
	TusResumable string
	// uploadLength represents the size of the entire upload in bytes.
	UploadLength *int64
	// The Upload-Defer-Length request and response header indicates that the size
	// of the upload is not known currently and will be transferred later.
	UploadDeferLength *int
	// A Client MAY include the Upload-Checksum header in a PATCH request. Once the
	// entire request has been received, the Server MUST verify the uploaded chunk
	// against the provided checksum using the specified algorithm.
	UploadChecksum *string
	// The Client MAY supply the Upload-Metadata header to add additional metadata
	// to the upload creation request.
	UploadMetadata *string
	// Length of the upload
	TusMaxSize *int64
}

PostPayload is the payload type of the tus service post method.

type PostRequestData

type PostRequestData struct {
	// Payload is the method payload.
	Payload *PostPayload
	// Body streams the HTTP request body.
	Body io.ReadCloser
}

PostRequestData holds both the payload and the HTTP request body reader of the "post" method.

type PostResult

type PostResult struct {
	// tusResumable represents a tus protocol version.
	TusResumable string
	// uploadOffset represents a byte offset within a resource.
	UploadOffset int64
	// The Upload-Expires response header indicates the time after which the
	// unfinished upload expires.
	UploadExpires *string
	// URL of created resource
	Location string
}

PostResult is the result type of the tus service post method.

type Service

type Service interface {
	// Clients use the HEAD request to determine the offset at which the upload
	// should be continued.
	Head(context.Context, *HeadPayload) (res *HeadResult, err error)
	// Clients use the PATCH method to start or resume an upload.
	Patch(context.Context, *PatchPayload, io.ReadCloser) (res *PatchResult, err error)
	// Clients use the OPTIONS method to gather information about the Server’s
	// current configuration.
	Options(context.Context) (res *OptionsResult, err error)
	// Clients use the POST method against a known upload creation URL to request a
	// new upload resource.
	Post(context.Context, *PostPayload, io.ReadCloser) (res *PostResult, err error)
	// Clients use the DELETE method to terminate completed and unfinished uploads
	// allowing the Server to free up used resources.
	Delete(context.Context, *DeletePayload) (res *DeleteResult, err error)
}

The tus service exposes the methods required to implement the tus protocol

Jump to

Keyboard shortcuts

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