Documentation ¶
Index ¶
- Variables
- func RegisterHookHandlerServer(s grpc.ServiceRegistrar, srv HookHandlerServer)
- type Event
- type FileInfo
- func (*FileInfo) Descriptor() ([]byte, []int)deprecated
- func (x *FileInfo) GetId() string
- func (x *FileInfo) GetIsFinal() bool
- func (x *FileInfo) GetIsPartial() bool
- func (x *FileInfo) GetMetaData() map[string]string
- func (x *FileInfo) GetOffset() int64
- func (x *FileInfo) GetPartialUploads() []string
- func (x *FileInfo) GetSize() int64
- func (x *FileInfo) GetSizeIsDeferred() bool
- func (x *FileInfo) GetStorage() map[string]string
- func (*FileInfo) ProtoMessage()
- func (x *FileInfo) ProtoReflect() protoreflect.Message
- func (x *FileInfo) Reset()
- func (x *FileInfo) String() string
- type FileInfoChanges
- func (*FileInfoChanges) Descriptor() ([]byte, []int)deprecated
- func (x *FileInfoChanges) GetId() string
- func (x *FileInfoChanges) GetMetaData() map[string]string
- func (x *FileInfoChanges) GetStorage() map[string]string
- func (*FileInfoChanges) ProtoMessage()
- func (x *FileInfoChanges) ProtoReflect() protoreflect.Message
- func (x *FileInfoChanges) Reset()
- func (x *FileInfoChanges) String() string
- type HTTPRequest
- func (*HTTPRequest) Descriptor() ([]byte, []int)deprecated
- func (x *HTTPRequest) GetHeader() map[string]string
- func (x *HTTPRequest) GetMethod() string
- func (x *HTTPRequest) GetRemoteAddr() string
- func (x *HTTPRequest) GetUri() string
- func (*HTTPRequest) ProtoMessage()
- func (x *HTTPRequest) ProtoReflect() protoreflect.Message
- func (x *HTTPRequest) Reset()
- func (x *HTTPRequest) String() string
- type HTTPResponse
- func (*HTTPResponse) Descriptor() ([]byte, []int)deprecated
- func (x *HTTPResponse) GetBody() string
- func (x *HTTPResponse) GetHeader() map[string]string
- func (x *HTTPResponse) GetStatusCode() int64
- func (*HTTPResponse) ProtoMessage()
- func (x *HTTPResponse) ProtoReflect() protoreflect.Message
- func (x *HTTPResponse) Reset()
- func (x *HTTPResponse) String() string
- type HookHandlerClient
- type HookHandlerServer
- type HookRequest
- type HookResponse
- func (*HookResponse) Descriptor() ([]byte, []int)deprecated
- func (x *HookResponse) GetChangeFileInfo() *FileInfoChanges
- func (x *HookResponse) GetHttpResponse() *HTTPResponse
- func (x *HookResponse) GetRejectUpload() bool
- func (x *HookResponse) GetStopUpload() bool
- func (*HookResponse) ProtoMessage()
- func (x *HookResponse) ProtoReflect() protoreflect.Message
- func (x *HookResponse) Reset()
- func (x *HookResponse) String() string
- type UnimplementedHookHandlerServer
- type UnsafeHookHandlerServer
Constants ¶
This section is empty.
Variables ¶
var File_pkg_hooks_grpc_proto_hook_proto protoreflect.FileDescriptor
var HookHandler_ServiceDesc = grpc.ServiceDesc{ ServiceName: "proto.HookHandler", HandlerType: (*HookHandlerServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "InvokeHook", Handler: _HookHandler_InvokeHook_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "pkg/hooks/grpc/proto/hook.proto", }
HookHandler_ServiceDesc is the grpc.ServiceDesc for HookHandler service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterHookHandlerServer ¶
func RegisterHookHandlerServer(s grpc.ServiceRegistrar, srv HookHandlerServer)
Types ¶
type Event ¶
type Event struct { // Upload contains information about the upload that caused this hook // to be fired. Upload *FileInfo `protobuf:"bytes,1,opt,name=upload,proto3" json:"upload,omitempty"` // HTTPRequest contains details about the HTTP request that reached // tusd. HttpRequest *HTTPRequest `protobuf:"bytes,2,opt,name=httpRequest,proto3" json:"httpRequest,omitempty"` // contains filtered or unexported fields }
Event represents an event from tusd which can be handled by the application.
func (*Event) Descriptor
deprecated
func (*Event) GetHttpRequest ¶
func (x *Event) GetHttpRequest() *HTTPRequest
func (*Event) ProtoMessage ¶
func (*Event) ProtoMessage()
func (*Event) ProtoReflect ¶
func (x *Event) ProtoReflect() protoreflect.Message
type FileInfo ¶
type FileInfo struct { // ID is the unique identifier of the upload resource. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Total file size in bytes specified in the NewUpload call Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` // Indicates whether the total file size is deferred until later SizeIsDeferred bool `protobuf:"varint,3,opt,name=sizeIsDeferred,proto3" json:"sizeIsDeferred,omitempty"` // Offset in bytes (zero-based) Offset int64 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` MetaData map[string]string `` /* 157-byte string literal not displayed */ // Indicates that this is a partial upload which will later be used to form // a final upload by concatenation. Partial uploads should not be processed // when they are finished since they are only incomplete chunks of files. IsPartial bool `protobuf:"varint,6,opt,name=isPartial,proto3" json:"isPartial,omitempty"` // Indicates that this is a final upload IsFinal bool `protobuf:"varint,7,opt,name=isFinal,proto3" json:"isFinal,omitempty"` // If the upload is a final one (see IsFinal) this will be a non-empty // ordered slice containing the ids of the uploads of which the final upload // will consist after concatenation. PartialUploads []string `protobuf:"bytes,8,rep,name=partialUploads,proto3" json:"partialUploads,omitempty"` // Storage contains information about where the data storage saves the upload, // for example a file path. The available values vary depending on what data // store is used. This map may also be nil. Storage map[string]string `` /* 155-byte string literal not displayed */ // contains filtered or unexported fields }
FileInfo contains information about a single upload resource.
func (*FileInfo) Descriptor
deprecated
func (*FileInfo) GetIsFinal ¶
func (*FileInfo) GetIsPartial ¶
func (*FileInfo) GetMetaData ¶
func (*FileInfo) GetPartialUploads ¶
func (*FileInfo) GetSizeIsDeferred ¶
func (*FileInfo) GetStorage ¶
func (*FileInfo) ProtoMessage ¶
func (*FileInfo) ProtoMessage()
func (*FileInfo) ProtoReflect ¶
func (x *FileInfo) ProtoReflect() protoreflect.Message
type FileInfoChanges ¶
type FileInfoChanges struct { // If ID is not empty, it will be passed to the data store, allowing // hooks to influence the upload ID. Be aware that a data store is not required to // respect a pre-defined upload ID and might overwrite or modify it. However, // all data stores in the github.com/tus/tusd package do respect pre-defined IDs. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // If MetaData is not nil, it replaces the entire user-defined meta data from // the upload creation request. You can add custom meta data fields this way // or ensure that only certain fields from the user-defined meta data are saved. // If you want to retain only specific entries from the user-defined meta data, you must // manually copy them into this MetaData field. // If you do not want to store any meta data, set this field to an empty map (`MetaData{}`). // If you want to keep the entire user-defined meta data, set this field to nil. MetaData map[string]string `` /* 157-byte string literal not displayed */ // If Storage is not nil, it is passed to the data store to allow for minor adjustments // to the upload storage (e.g. destination file name). The details are specific for each // data store and should be looked up in their respective documentation. // Please be aware that this behavior is currently not supported by any data store in // the github.com/tus/tusd package. Storage map[string]string `` /* 155-byte string literal not displayed */ // contains filtered or unexported fields }
FileInfoChanges collects changes the should be made to a FileInfo object. This can be done using the PreUploadCreateCallback to modify certain properties before an upload is created. Properties which should not be modified (e.g. Size or Offset) are intentionally left out here.
func (*FileInfoChanges) Descriptor
deprecated
func (*FileInfoChanges) Descriptor() ([]byte, []int)
Deprecated: Use FileInfoChanges.ProtoReflect.Descriptor instead.
func (*FileInfoChanges) GetId ¶
func (x *FileInfoChanges) GetId() string
func (*FileInfoChanges) GetMetaData ¶
func (x *FileInfoChanges) GetMetaData() map[string]string
func (*FileInfoChanges) GetStorage ¶
func (x *FileInfoChanges) GetStorage() map[string]string
func (*FileInfoChanges) ProtoMessage ¶
func (*FileInfoChanges) ProtoMessage()
func (*FileInfoChanges) ProtoReflect ¶
func (x *FileInfoChanges) ProtoReflect() protoreflect.Message
func (*FileInfoChanges) Reset ¶
func (x *FileInfoChanges) Reset()
func (*FileInfoChanges) String ¶
func (x *FileInfoChanges) String() string
type HTTPRequest ¶
type HTTPRequest struct { // Method is the HTTP method, e.g. POST or PATCH. Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` // URI is the full HTTP request URI, e.g. /files/fooo. Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"` // RemoteAddr contains the network address that sent the request. RemoteAddr string `protobuf:"bytes,3,opt,name=remoteAddr,proto3" json:"remoteAddr,omitempty"` // Header contains all HTTP headers as present in the HTTP request. Header map[string]string `` /* 153-byte string literal not displayed */ // contains filtered or unexported fields }
HTTPRequest contains basic details of an incoming HTTP request.
func (*HTTPRequest) Descriptor
deprecated
func (*HTTPRequest) Descriptor() ([]byte, []int)
Deprecated: Use HTTPRequest.ProtoReflect.Descriptor instead.
func (*HTTPRequest) GetHeader ¶
func (x *HTTPRequest) GetHeader() map[string]string
func (*HTTPRequest) GetMethod ¶
func (x *HTTPRequest) GetMethod() string
func (*HTTPRequest) GetRemoteAddr ¶
func (x *HTTPRequest) GetRemoteAddr() string
func (*HTTPRequest) GetUri ¶
func (x *HTTPRequest) GetUri() string
func (*HTTPRequest) ProtoMessage ¶
func (*HTTPRequest) ProtoMessage()
func (*HTTPRequest) ProtoReflect ¶
func (x *HTTPRequest) ProtoReflect() protoreflect.Message
func (*HTTPRequest) Reset ¶
func (x *HTTPRequest) Reset()
func (*HTTPRequest) String ¶
func (x *HTTPRequest) String() string
type HTTPResponse ¶
type HTTPResponse struct { // StatusCode is status code, e.g. 200 or 400. StatusCode int64 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"` // Header contains additional HTTP headers for the response. Header map[string]string `` /* 153-byte string literal not displayed */ // Body is the response body. Body string `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"` // contains filtered or unexported fields }
HTTPResponse contains basic details of an outgoing HTTP response.
func (*HTTPResponse) Descriptor
deprecated
func (*HTTPResponse) Descriptor() ([]byte, []int)
Deprecated: Use HTTPResponse.ProtoReflect.Descriptor instead.
func (*HTTPResponse) GetBody ¶
func (x *HTTPResponse) GetBody() string
func (*HTTPResponse) GetHeader ¶
func (x *HTTPResponse) GetHeader() map[string]string
func (*HTTPResponse) GetStatusCode ¶
func (x *HTTPResponse) GetStatusCode() int64
func (*HTTPResponse) ProtoMessage ¶
func (*HTTPResponse) ProtoMessage()
func (*HTTPResponse) ProtoReflect ¶
func (x *HTTPResponse) ProtoReflect() protoreflect.Message
func (*HTTPResponse) Reset ¶
func (x *HTTPResponse) Reset()
func (*HTTPResponse) String ¶
func (x *HTTPResponse) String() string
type HookHandlerClient ¶
type HookHandlerClient interface { // InvokeHook is invoked for every hook that is executed. HookRequest contains the // corresponding information about the hook type, the involved upload, and // causing HTTP request. // The return value HookResponse allows to stop or reject an upload, as well as modifying // the HTTP response. See the documentation for HookResponse for more details. InvokeHook(ctx context.Context, in *HookRequest, opts ...grpc.CallOption) (*HookResponse, error) }
HookHandlerClient is the client API for HookHandler service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewHookHandlerClient ¶
func NewHookHandlerClient(cc grpc.ClientConnInterface) HookHandlerClient
type HookHandlerServer ¶
type HookHandlerServer interface { // InvokeHook is invoked for every hook that is executed. HookRequest contains the // corresponding information about the hook type, the involved upload, and // causing HTTP request. // The return value HookResponse allows to stop or reject an upload, as well as modifying // the HTTP response. See the documentation for HookResponse for more details. InvokeHook(context.Context, *HookRequest) (*HookResponse, error) // contains filtered or unexported methods }
HookHandlerServer is the server API for HookHandler service. All implementations must embed UnimplementedHookHandlerServer for forward compatibility
type HookRequest ¶
type HookRequest struct { // Type is the name of the hook. Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Event contains the involved upload and causing HTTP request. Event *Event `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"` // contains filtered or unexported fields }
HookRequest contains the information about the hook type, the involved upload, and causing HTTP request.
func (*HookRequest) Descriptor
deprecated
func (*HookRequest) Descriptor() ([]byte, []int)
Deprecated: Use HookRequest.ProtoReflect.Descriptor instead.
func (*HookRequest) GetEvent ¶
func (x *HookRequest) GetEvent() *Event
func (*HookRequest) GetType ¶
func (x *HookRequest) GetType() string
func (*HookRequest) ProtoMessage ¶
func (*HookRequest) ProtoMessage()
func (*HookRequest) ProtoReflect ¶
func (x *HookRequest) ProtoReflect() protoreflect.Message
func (*HookRequest) Reset ¶
func (x *HookRequest) Reset()
func (*HookRequest) String ¶
func (x *HookRequest) String() string
type HookResponse ¶
type HookResponse struct { // HTTPResponse's fields can be filled to modify the HTTP response. // This is only possible for pre-create, pre-finish and post-receive hooks. // For other hooks this value is ignored. // If multiple hooks modify the HTTP response, a later hook may overwrite the // modified values from a previous hook (e.g. if multiple post-receive hooks // are executed). // Example usages: Send an error to the client if RejectUpload/StopUpload are // set in the pre-create/post-receive hook. Send more information to the client // in the pre-finish hook. HttpResponse *HTTPResponse `protobuf:"bytes,1,opt,name=httpResponse,proto3" json:"httpResponse,omitempty"` // RejectUpload will cause the upload to be rejected and not be created during // POST request. This value is only respected for pre-create hooks. For other hooks, // it is ignored. Use the HTTPResponse field to send details about the rejection // to the client. RejectUpload bool `protobuf:"varint,2,opt,name=rejectUpload,proto3" json:"rejectUpload,omitempty"` // ChangeFileInfo can be set to change selected properties of an upload before // it has been created. See the handler.FileInfoChanges type for more details. // Changes are applied on a per-property basis, meaning that specifying just // one property leaves all others unchanged. // This value is only respected for pre-create hooks. ChangeFileInfo *FileInfoChanges `protobuf:"bytes,4,opt,name=changeFileInfo,proto3" json:"changeFileInfo,omitempty"` // StopUpload will cause the upload to be stopped during a PATCH request. // This value is only respected for post-receive hooks. For other hooks, // it is ignored. Use the HTTPResponse field to send details about the stop // to the client. StopUpload bool `protobuf:"varint,3,opt,name=stopUpload,proto3" json:"stopUpload,omitempty"` // contains filtered or unexported fields }
HookResponse is the response after a hook is executed.
func (*HookResponse) Descriptor
deprecated
func (*HookResponse) Descriptor() ([]byte, []int)
Deprecated: Use HookResponse.ProtoReflect.Descriptor instead.
func (*HookResponse) GetChangeFileInfo ¶
func (x *HookResponse) GetChangeFileInfo() *FileInfoChanges
func (*HookResponse) GetHttpResponse ¶
func (x *HookResponse) GetHttpResponse() *HTTPResponse
func (*HookResponse) GetRejectUpload ¶
func (x *HookResponse) GetRejectUpload() bool
func (*HookResponse) GetStopUpload ¶
func (x *HookResponse) GetStopUpload() bool
func (*HookResponse) ProtoMessage ¶
func (*HookResponse) ProtoMessage()
func (*HookResponse) ProtoReflect ¶
func (x *HookResponse) ProtoReflect() protoreflect.Message
func (*HookResponse) Reset ¶
func (x *HookResponse) Reset()
func (*HookResponse) String ¶
func (x *HookResponse) String() string
type UnimplementedHookHandlerServer ¶
type UnimplementedHookHandlerServer struct { }
UnimplementedHookHandlerServer must be embedded to have forward compatible implementations.
func (UnimplementedHookHandlerServer) InvokeHook ¶
func (UnimplementedHookHandlerServer) InvokeHook(context.Context, *HookRequest) (*HookResponse, error)
type UnsafeHookHandlerServer ¶
type UnsafeHookHandlerServer interface {
// contains filtered or unexported methods
}
UnsafeHookHandlerServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to HookHandlerServer will result in compilation errors.