web

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package web contains HTTP handlers methods. There are 2 URLs: "/" - GET index page "/upload" - POST save file and settings "/<hash>" - GET and POST get file

Index

Constants

View Source
const (
	// TTL is default TTL value. If it conflicts with custom configuration then minimum value will be used.
	TTL = 86400
	// Times is default times value
	Times = 1
	// PasswordLength is default password length in bytes for auto-generated ones.
	PasswordLength = 8
)

Variables

This section is empty.

Functions

func Download

func Download(w io.Writer, r *http.Request, cfg *conf.Cfg) (int, error)

Download returns a decrypted file.

func Error

func Error(w io.Writer, cfg *conf.Cfg, code int, msg string, tplName string) int

Error sets error page. It returns http status code.

func ErrorUploadShort added in v1.1.0

func ErrorUploadShort(w io.Writer, cfg *conf.Cfg, code int, msg string) int

ErrorUploadShort sets error response. It returns http status code.

func Index

func Index(w io.Writer, _ *http.Request, cfg *conf.Cfg) (int, error)

Index is a index page HTTP handler.

func Upload

func Upload(w io.Writer, r *http.Request, cfg *conf.Cfg) (int, error)

Upload gets an incoming upload request, encrypts and saves file to the storage.

func UploadShort added in v1.1.0

func UploadShort(w io.Writer, r *http.Request, cfg *conf.Cfg) (int, error)

UploadShort gets an incoming upload request, encrypts and saves file to the storage. It differs from Upload method, only file field is required, a response content-type is "plain/text".

Types

type IndexData

type IndexData struct {
	Err     string
	Msg     string
	MaxSize int
}

IndexData is a struct for index page init data.

Jump to

Keyboard shortcuts

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