Documentation ¶
Index ¶
- func GeneralBadRequestError(req *http.Request, res http.ResponseWriter, cfgManager config.Manager, ...)
- func GeneralForbiddenError(req *http.Request, res http.ResponseWriter, cfgManager config.Manager, ...)
- func GeneralInternalServerError(req *http.Request, res http.ResponseWriter, cfgManager config.Manager, ...)
- func GeneralNotFoundError(req *http.Request, res http.ResponseWriter, cfgManager config.Manager)
- func GeneralUnauthorizedError(req *http.Request, res http.ResponseWriter, cfgManager config.Manager, ...)
- func HTTPMiddleware(cfgManager config.Manager, targetKey string) func(next http.Handler) http.Handler
- func SetResponseHandlerInContext(ctx context.Context, resH ResponseHandler) context.Context
- type DeleteInput
- type Entry
- type PutInput
- type ResponseHandler
- type StreamInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneralBadRequestError ¶
func GeneralForbiddenError ¶
func GeneralNotFoundError ¶
func HTTPMiddleware ¶
func HTTPMiddleware(cfgManager config.Manager, targetKey string) func(next http.Handler) http.Handler
HTTPMiddleware will add a new response handler on each request.
func SetResponseHandlerInContext ¶
func SetResponseHandlerInContext(ctx context.Context, resH ResponseHandler) context.Context
SetResponseHandlerInContext will set a response handler object in a context.
Types ¶
type Entry ¶
type Entry struct { LastModified time.Time Type string ETag string Name string Key string Path string Size int64 }
Entry Entry with path for internal use (template).
type PutInput ¶
type PutInput struct { Metadata map[string]string Key string ContentType string StorageClass string Filename string ContentSize int64 }
PutInput represents a put input.
type ResponseHandler ¶
type ResponseHandler interface { // TargetList will answer for the target list response. TargetList() // Put will answer for the put response. Put( loadFileContent func(ctx context.Context, path string) (string, error), input *PutInput, ) // Delete will answer for the delete response. Delete( loadFileContent func(ctx context.Context, path string) (string, error), input *DeleteInput, ) // NotModified will answer with a Not Modified status code. NotModified() // PreconditionFailed will answer with a Precondition Failed status code. PreconditionFailed() // RedirectWithTrailingSlash will redirect with a trailing slash. RedirectWithTrailingSlash() // RedirectTo will redirect to an url. RedirectTo(url string) // StreamFile will stream file in output. // Error will be managed outside of this function because of the workflow in the caller function. StreamFile( loadFileContent func(ctx context.Context, path string) (string, error), input *StreamInput, ) error // FoldersFilesList will answer with the folder list output coming from template. FoldersFilesList( loadFileContent func(ctx context.Context, path string) (string, error), entries []*Entry, ) // NotFoundError will answer for not found error. NotFoundError( loadFileContent func(ctx context.Context, path string) (string, error), ) // ForbiddenError will answer for forbidden error. ForbiddenError( loadFileContent func(ctx context.Context, path string) (string, error), err error, ) // BadRequestError will answer for bad request error. BadRequestError( loadFileContent func(ctx context.Context, path string) (string, error), err error, ) UnauthorizedError( loadFileContent func(ctx context.Context, path string) (string, error), err error, ) // InternalServerError will answer for internal server error. InternalServerError( loadFileContent func(ctx context.Context, path string) (string, error), err error, ) // UpdateRequestAndResponse will update request and response in object. // This will used to update request and response in order to have the latest context values. UpdateRequestAndResponse(req *http.Request, res http.ResponseWriter) // GetRequest will return the actual request object. GetRequest() *http.Request }
ResponseHandler will handle responses.
func GetResponseHandlerFromContext ¶
func GetResponseHandlerFromContext(ctx context.Context) ResponseHandler
GetResponseHandlerFromContext will return the response handler object from context.
func NewHandler ¶
func NewHandler(req *http.Request, res http.ResponseWriter, cfgManager config.Manager, targetKey string) ResponseHandler
NewHandler will return a new response handler object.
type StreamInput ¶
type StreamInput struct { LastModified time.Time Body io.ReadCloser Metadata map[string]string CacheControl string Expires string ContentDisposition string ContentEncoding string ContentLanguage string ContentRange string ContentType string ETag string ContentLength int64 }
StreamInput represents a stream input file.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.