datadump

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(o interface{}, filePrefix string, logger *slog.Logger, compress bool) http.Handler

Handler returns http.Handler that will call DataDump on every o field that implements Interface. If filePrefix is not blank Content-Disposition HTTP header will be added to the response. The response body will be the tar archive containing binary files named by the o fields that implement Interface. The provided interface can be a struct or a map with string keys and interface{} values that will be checked if they implement the Interface. If compression argument is set to true, the response will be compressed with gzip default options.

Types

type File

type File struct {
	Name    string
	Length  int64
	ModTime *time.Time
	Body    io.ReadCloser
}

File defines a structure that holds dump metadata and body as reader interface. Body must be closed after the read is done.

type Interface

type Interface interface {
	DataDump(fn func(f File) (err error)) (err error)
}

Interface defines method to retrieve data Dump. If ifModifiedSince is not nil and data is not changed since provided time, both return values, Dump and error, will be nil.

type InterfaceFunc

type InterfaceFunc func(fn func(f File) (err error)) (err error)

InterfaceFunc implements Interface as a single function that can be assigned.

func (InterfaceFunc) DataDump

func (f InterfaceFunc) DataDump(fn func(f File) (err error)) (err error)

DataDump calls the type function.

Jump to

Keyboard shortcuts

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