parser

package
v0.0.0-...-5597880 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAuthorization          = "Authorization"
	HeaderContentType            = "Content-Type"
	ContentTypeMultipartFormData = "multipart/form-data"
)

Variables

View Source
var ErrNotExist = errors.New("object not exist")

Functions

func BearerTokenFromRequest

func BearerTokenFromRequest(header string, r *http.Request) (string, error)

Types

type DataReadCloser

type DataReadCloser struct {
	// contains filtered or unexported fields
}

DataReadCloser provides a transparent way to read data from a temporary file on disk

func (*DataReadCloser) Close

func (f *DataReadCloser) Close() error

Close and remove the temporary file

func (*DataReadCloser) Read

func (f *DataReadCloser) Read(p []byte) (n int, err error)

Read the data from the temporary file

type File

type File struct {
	Path   string
	Reader io.ReadCloser
}

File represents a file in a multipart form

type MultipartForm

type MultipartForm struct {
	// contains filtered or unexported fields
}

func MultipartFormFromRequest

func MultipartFormFromRequest(r *http.Request) (*MultipartForm, error)

func (*MultipartForm) DeserializedObject

func (f *MultipartForm) DeserializedObject(name string, v interface{}) error

func (*MultipartForm) Files

func (f *MultipartForm) Files() []*File

func (*MultipartForm) Object

func (f *MultipartForm) Object(name string) (*Object, error)

func (*MultipartForm) Process

func (f *MultipartForm) Process(objectNames []string) error

Process reads the form body and parses it into objects or files, where objectNames is a list of form names that should be treated as objects Note: objectNames take precedence over files

type Object

type Object struct {
	Name string
	Data []byte
}

Object represents a generic object in a multipart form

func (*Object) FromJSON

func (o *Object) FromJSON(v interface{}) error

FromJSON unmarshals the data of the object into the provided value

Jump to

Keyboard shortcuts

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