models

package
v0.0.0-...-51c7e80 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEncoding = httpencoding.EncodingZstd

Functions

func ContentHash

func ContentHash(r io.Reader) (string, error)

func ContentHashBytes

func ContentHashBytes(v []byte) string

Types

type FileContent

type FileContent struct {
	Model
	Hash        string `gorm:"unique"`
	Name        string
	Size        int64 `gorm:"index"`
	Ext         string
	ContentType string
	Content     []byte
	Extension   datatypes.JSON
	Attributes  datatypes.JSON
}

func (FileContent) ConflictColumns

func (FileContent) ConflictColumns() []clause.Column

type FileRef

type FileRef struct {
	Model
	Hash string       `gorm:"uniqueIndex:idx_file_ref_hash_url"`
	URL  string       `gorm:"uniqueIndex:idx_file_ref_hash_url"`
	File *FileContent `gorm:"foreignKey:Hash;references:Hash"`
	Name string
}

func (FileRef) ConflictColumns

func (FileRef) ConflictColumns() []clause.Column

type HTTPResponse

type HTTPResponse struct {
	Model
	Method string `gorm:"uniqueIndex:idx_http_responses_method_url"`
	URL    string `gorm:"uniqueIndex:idx_http_responses_method_url"`
	Host   string
	Path   string

	Proto           string
	StatusCode      int
	Header          datatypes.JSON
	RawSize         int64 // size before encoding
	BodySize        int64 // size of Body
	Body            []byte
	ContentType     string
	ContentEncoding string // gzip, deflate, br, zstd, identity
	ContentHash     string // sha2-256 for raw data for file
	FileName        string
}

func (HTTPResponse) ConflictColumns

func (HTTPResponse) ConflictColumns() []clause.Column

func (*HTTPResponse) GetBody

func (m *HTTPResponse) GetBody() (rc io.ReadCloser, err error)

func (*HTTPResponse) GetResponse

func (m *HTTPResponse) GetResponse(req *http.Request) (resp *http.Response, err error)

func (*HTTPResponse) ReadAll

func (m *HTTPResponse) ReadAll() (out []byte, err error)

func (*HTTPResponse) SetResponse

func (m *HTTPResponse) SetResponse(resp *http.Response) (err error)

type Model

type Model struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time

	DB *gorm.DB `gorm:"-" mapstructure:"-" json:"-" yaml:"-"`
}

func (*Model) AfterFind

func (model *Model) AfterFind(tx *gorm.DB) (err error)

func (*Model) BeforeSave

func (model *Model) BeforeSave(tx *gorm.DB) (err error)

func (*Model) GetDB

func (model *Model) GetDB() *gorm.DB

func (*Model) GetModel

func (model *Model) GetModel() *Model

Jump to

Keyboard shortcuts

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