resource

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package resource provides data transfer objects for NVGD's protocol and filters.

Index

Constants

View Source
const (
	// ContentType is for header.
	ContentType = "Content-Type"

	// Filename is for header.
	Filename = "File-Name"
)

Variables

View Source
var Mime = map[string]string{
	".css":  "text/css",
	".html": "text/html",
	".js":   "text/javascript",
	".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
}

Mime is known MIME table.

Functions

This section is empty.

Types

type Options

type Options map[string]interface{}

Options holds option properties of Resource.

func (Options) Bool

func (opts Options) Bool(key string) (value bool, ok bool)

Bool gets a value as bool.

func (Options) Int

func (opts Options) Int(key string) (value int, ok bool)

Int gets a value as int.

func (Options) String

func (opts Options) String(key string) (value string, ok bool)

String gets a value as string.

func (Options) Strings

func (opts Options) Strings(key string) (value []string, ok bool)

Strings gets a value as []string.

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

ReadSeekCloser combines io.Reader, io.Seeker and io.Closer.

type Resource

type Resource struct {
	io.ReadCloser
	Options
}

Resource packs ReadCloser and its meta info.

func New

func New(rc io.ReadCloser) *Resource

New creates a Resource from ReadCloser.

func NewRedirect added in v1.12.0

func NewRedirect(redirectPath string) *Resource

NewRedirect creates a Resource to redirect to another path.

func NewString

func NewString(s string) *Resource

NewString creates a Resource with string as content.

func (*Resource) GuessContentType

func (r *Resource) GuessContentType(s string) *Resource

GuessContentType guess a content-type from argument string.

func (*Resource) Put

func (r *Resource) Put(name string, value interface{}) *Resource

Put puts a pair of name and value as an option.

func (*Resource) PutContentType

func (r *Resource) PutContentType(s string) *Resource

PutContentType puts a content-type option.

func (*Resource) PutFilename

func (r *Resource) PutFilename(s string) *Resource

PutFilename puts a filenaem option.

func (*Resource) PutString

func (r *Resource) PutString(name, value string) *Resource

PutString puts a string as an option. When value is empty string, it deletes the option.

func (*Resource) Raw

func (r *Resource) Raw() io.ReadCloser

Raw returns underlying io.ReadCloser in this resource.

func (*Resource) ReadSeekCloser

func (r *Resource) ReadSeekCloser() (ReadSeekCloser, bool)

ReadSeekCloser obtains ReadSeekCloser if it could.

func (*Resource) Wrap

func (r *Resource) Wrap(rc io.ReadCloser) *Resource

Wrap creates new Resource with a io.ReadCloser which inherits properties from current Resource.

Jump to

Keyboard shortcuts

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