request

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package request provides functions for handling HTTP requests

Index

Constants

This section is empty.

Variables

View Source
var (
	// Logger holds the global logger that can be override by another logger
	Logger *log.Logger

	// ContextKeys holds request context keys
	ContextKeys = struct {
		PathPrefix contextKey
	}{
		PathPrefix: "PathPrefix",
	}
)

Functions

This section is empty.

Types

type Error

type Error struct {
	ID         string      `json:"id,omitempty"`
	StatusCode int         `json:"statusCode,omitempty"`
	Message    string      `json:"message,omitempty"`
	Error      interface{} `json:"error,omitempty"`
	Internal   interface{} `json:"-"`
}

Error represents an HTTP error

type FormFile

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

FormFile represents a form file

func (*FormFile) ContentType

func (ff *FormFile) ContentType() string

ContentType returns the content type of the form file

func (*FormFile) CopyTo

func (ff *FormFile) CopyTo(dst io.Writer) (written int64, err error)

CopyTo copies the form file to the given destination

func (*FormFile) FieldName

func (ff *FormFile) FieldName() string

FieldName returns the field name of the form file

func (*FormFile) FileHeader

func (ff *FormFile) FileHeader() *multipart.FileHeader

FileHeader returns the file header for the form file

func (*FormFile) FileName

func (ff *FormFile) FileName() string

FileName returns the file name of the form file

func (*FormFile) Multiple

func (ff *FormFile) Multiple() bool

Multiple returns the multiple value of the form file

func (*FormFile) SaveFile

func (ff *FormFile) SaveFile(name string, perm os.FileMode) error

SaveFile saves the form file

type Options

type Options struct {
	// Request holds the request
	Request *http.Request
	// Writer holds the response writer
	Writer http.ResponseWriter
	// MaxMemory holds the maximum memory for multi part form parsing
	MaxMemory int64
}

Options represents the options than can be set when creating a new request

type Request

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

Request represents an HTTP request

func New

func New(o Options) *Request

New returns a new HTTP request by the given options

func (*Request) ContentType

func (request *Request) ContentType() string

ContentType returns the request content type

func (*Request) FormFiles

func (request *Request) FormFiles() []FormFile

FormFiles returns the form files

func (*Request) Reply

func (request *Request) Reply(rv interface{})

Reply replies an HTTP request

type Success

type Success struct {
	ID         string      `json:"id,omitempty"`
	StatusCode int         `json:"statusCode,omitempty"`
	Message    string      `json:"message,omitempty"`
	Data       interface{} `json:"data,omitempty"`
	Internal   interface{} `json:"-"`
}

Success represents a successful HTTP response

Jump to

Keyboard shortcuts

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