Documentation ¶
Index ¶
- func GetFilePath(ctx context.Context) (string, bool)
- func GetUpload(ctx context.Context) (model.Upload, bool)
- func MustGetFilePath(ctx context.Context) string
- func MustGetUpload(ctx context.Context) model.Upload
- func SetFilePath(ctx context.Context, path string) context.Context
- func SetUpload(ctx context.Context, upload model.Upload) context.Context
- func UploadState(states ...model.UploadState) func(next http.Handler) http.Handler
- func ValidateFilePath(next http.Handler) http.Handler
- type Handler
- func (h *Handler) Create(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteFile(w http.ResponseWriter, r *http.Request)
- func (h *Handler) FetchUpload(next http.Handler) http.Handler
- func (h *Handler) Find(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Get(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetErrors(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetFile(w http.ResponseWriter, r *http.Request)
- func (h *Handler) PutFile(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFilePath ¶
GetFilePath returns the file path from the context. If the context does not contain a file path, the second return value will be false.
func GetUpload ¶
GetUpload returns a model.Upload instance from the context. If the context does not contain an upload instance, the second return value will be false.
func MustGetFilePath ¶
MustGetFilePath returns the file path from the context. In contrast to GetFilePath this function panics if the context does not contain a file path.
func MustGetUpload ¶
MustGetUpload returns a model.Upload instance from the context. In contrast to GetUpload this function panics if the context does not contain an upload instance.
func SetFilePath ¶
SetFilePath sets the file path in ctx.
func UploadState ¶
UploadState is a middleware that checks if the upload is in one of the allowed states.
func ValidateFilePath ¶
ValidateFilePath is a middleware that validates the file path within an upload syntactically. If this middleware passes it is not guaranteed that the path actually exists. It is also not guaranteed that the path is allowed for a specific endpoint.
The root directory is normalized to ".".
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the /v1/uploads endpoints.
func NewHandler ¶
func NewHandler( logger *slog.Logger, uploadRepo upload.Repository, uploadStore upload.Store, ) *Handler
NewHandler creates a new Handler instance using the specified service.
func (*Handler) Create ¶
func (h *Handler) Create(w http.ResponseWriter, r *http.Request)
Create implements the POST /v1/uploads endpoint.
func (*Handler) Delete ¶
func (h *Handler) Delete(w http.ResponseWriter, r *http.Request)
Delete implements the DELETE /v1/uploads/{uuid} endpoint.
func (*Handler) DeleteFile ¶
func (h *Handler) DeleteFile(w http.ResponseWriter, r *http.Request)
DeleteFile implements the DELETE /v1/uploads/{uuid}/files/* endpoint.
func (*Handler) FetchUpload ¶
FetchUpload is a middleware that fetches the model.Upload instance identified by the request and stores it in the request context.
func (*Handler) Find ¶
func (h *Handler) Find(w http.ResponseWriter, r *http.Request)
Find implements the GET /v1/uploads endpoint.
func (*Handler) Get ¶
func (h *Handler) Get(w http.ResponseWriter, r *http.Request)
Get implements the GET /v1/uploads/{uuid} endpoint.
func (*Handler) GetErrors ¶
func (h *Handler) GetErrors(w http.ResponseWriter, r *http.Request)
GetErrors implements the GET /v1/uploads/{uuid}/errors endpoint.
func (*Handler) GetFile ¶
func (h *Handler) GetFile(w http.ResponseWriter, r *http.Request)
GetFile implements the GET /v1/uploads/{uuid}/files/* endpoint.