httputils

package
v0.0.0-...-a5c1f10 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: BSD-2-Clause Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefinedStream

type DefinedStream interface {
	SeekableStream
	Size() int64
	ModTime() time.Time
}

func NewStreamFromFile

func NewStreamFromFile(file *os.File) DefinedStream

type FastHTTPContext

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

func NewRequestContextFromFastHttp

func NewRequestContextFromFastHttp(server *Server, ctx *fasthttp.RequestCtx) *FastHTTPContext

func (*FastHTTPContext) AddResponseHeader

func (c *FastHTTPContext) AddResponseHeader(name string, value string)

func (*FastHTTPContext) AddTiming

func (c *FastHTTPContext) AddTiming(name string, desc string, d time.Duration)

func (*FastHTTPContext) AddTimingInformational

func (c *FastHTTPContext) AddTimingInformational(name string, desc string)

func (*FastHTTPContext) DoRedirect

func (c *FastHTTPContext) DoRedirect(location string, code int)

func (*FastHTTPContext) GetBody

func (c *FastHTTPContext) GetBody() io.Reader

func (*FastHTTPContext) GetConnectionTime

func (c *FastHTTPContext) GetConnectionTime() time.Time

func (*FastHTTPContext) GetExtraHeaders

func (c *FastHTTPContext) GetExtraHeaders() map[string]string

func (*FastHTTPContext) GetHost

func (c *FastHTTPContext) GetHost() string

func (*FastHTTPContext) GetPath

func (c *FastHTTPContext) GetPath() string

func (*FastHTTPContext) GetProtocol

func (c *FastHTTPContext) GetProtocol() string

func (*FastHTTPContext) GetRequestHeader

func (c *FastHTTPContext) GetRequestHeader(name string) string

func (*FastHTTPContext) GetRequestTime

func (c *FastHTTPContext) GetRequestTime() time.Time

func (*FastHTTPContext) GetResponseHeader

func (c *FastHTTPContext) GetResponseHeader(name string) string

func (*FastHTTPContext) GetTLSCipher

func (c *FastHTTPContext) GetTLSCipher() uint16

func (*FastHTTPContext) GetTLSServerName

func (c *FastHTTPContext) GetTLSServerName() string

func (*FastHTTPContext) GetTLSVersion

func (c *FastHTTPContext) GetTLSVersion() uint16

func (*FastHTTPContext) IsGet

func (c *FastHTTPContext) IsGet() bool

func (*FastHTTPContext) IsHead

func (c *FastHTTPContext) IsHead() bool

func (*FastHTTPContext) IsOptions

func (c *FastHTTPContext) IsOptions() bool

func (*FastHTTPContext) IsPost

func (c *FastHTTPContext) IsPost() bool

func (*FastHTTPContext) ServeBytes

func (c *FastHTTPContext) ServeBytes(content []byte)

func (*FastHTTPContext) ServeStream

func (c *FastHTTPContext) ServeStream(stream Stream)

func (*FastHTTPContext) SetResponseCode

func (c *FastHTTPContext) SetResponseCode(code int)

func (*FastHTTPContext) SetResponseHeader

func (c *FastHTTPContext) SetResponseHeader(name string, value string)

type FastHTTPRequestServer

type FastHTTPRequestServer func(ctx *fasthttp.RequestCtx) RequestContext

type FileStream

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

func (*FileStream) Close

func (fs *FileStream) Close() error

func (*FileStream) ModTime

func (fs *FileStream) ModTime() time.Time

func (*FileStream) Read

func (fs *FileStream) Read(p []byte) (n int, err error)

func (*FileStream) Seek

func (fs *FileStream) Seek(offset int64, whence int) (int64, error)

func (*FileStream) Size

func (fs *FileStream) Size() int64

type NetHTTPContext

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

func NewRequestContextFromHttp

func NewRequestContextFromHttp(server *Server, w http.ResponseWriter, r *http.Request) *NetHTTPContext

func (*NetHTTPContext) AddResponseHeader

func (c *NetHTTPContext) AddResponseHeader(name string, value string)

func (*NetHTTPContext) AddTiming

func (c *NetHTTPContext) AddTiming(name string, desc string, d time.Duration)

func (*NetHTTPContext) AddTimingInformational

func (c *NetHTTPContext) AddTimingInformational(name string, desc string)

func (*NetHTTPContext) DoRedirect

func (c *NetHTTPContext) DoRedirect(location string, code int)

func (*NetHTTPContext) GetBody

func (c *NetHTTPContext) GetBody() io.Reader

func (*NetHTTPContext) GetConnectionTime

func (c *NetHTTPContext) GetConnectionTime() time.Time

func (*NetHTTPContext) GetExtraHeaders

func (c *NetHTTPContext) GetExtraHeaders() map[string]string

func (*NetHTTPContext) GetHost

func (c *NetHTTPContext) GetHost() string

func (*NetHTTPContext) GetPath

func (c *NetHTTPContext) GetPath() string

func (*NetHTTPContext) GetProtocol

func (c *NetHTTPContext) GetProtocol() string

func (*NetHTTPContext) GetRequestHeader

func (c *NetHTTPContext) GetRequestHeader(name string) string

func (*NetHTTPContext) GetRequestTime

func (c *NetHTTPContext) GetRequestTime() time.Time

func (*NetHTTPContext) GetResponseHeader

func (c *NetHTTPContext) GetResponseHeader(name string) string

func (*NetHTTPContext) GetTLSCipher

func (c *NetHTTPContext) GetTLSCipher() uint16

func (*NetHTTPContext) GetTLSServerName

func (c *NetHTTPContext) GetTLSServerName() string

func (*NetHTTPContext) GetTLSVersion

func (c *NetHTTPContext) GetTLSVersion() uint16

func (*NetHTTPContext) IsGet

func (c *NetHTTPContext) IsGet() bool

func (*NetHTTPContext) IsHead

func (c *NetHTTPContext) IsHead() bool

func (*NetHTTPContext) IsOptions

func (c *NetHTTPContext) IsOptions() bool

func (*NetHTTPContext) IsPost

func (c *NetHTTPContext) IsPost() bool

func (*NetHTTPContext) ServeBytes

func (c *NetHTTPContext) ServeBytes(content []byte)

func (*NetHTTPContext) ServeStream

func (c *NetHTTPContext) ServeStream(stream Stream)

func (*NetHTTPContext) SetResponseCode

func (c *NetHTTPContext) SetResponseCode(code int)

func (*NetHTTPContext) SetResponseHeader

func (c *NetHTTPContext) SetResponseHeader(name string, value string)

type NetHTTPRequestServer

type NetHTTPRequestServer func(w http.ResponseWriter, r *http.Request) RequestContext

type RequestContext

type RequestContext interface {
	GetPath() string
	GetConnectionTime() time.Time
	GetRequestTime() time.Time
	GetTLSServerName() string
	GetBody() io.Reader
	GetHost() string
	GetProtocol() string
	GetTLSVersion() uint16
	GetTLSCipher() uint16
	GetRequestHeader(name string) string
	GetResponseHeader(name string) string
	AddResponseHeader(name string, value string)
	SetResponseHeader(name string, value string)

	ServeStream(stream Stream)
	ServeBytes(content []byte)
	SetResponseCode(code int)
	DoRedirect(location string, code int)

	IsGet() bool
	IsPost() bool
	IsOptions() bool
	IsHead() bool

	GetExtraHeaders() map[string]string

	AddTiming(name string, desc string, d time.Duration)
	AddTimingInformational(name string, desc string)
}

type RequestHandler

type RequestHandler func(ctx RequestContext)

type SeekableStream

type SeekableStream interface {
	Stream
	io.Seeker
}

type Server

type Server struct {
	ListenAddress         string
	TLSConfig             *tlsutils.Configuration
	UseFastHTTP           bool
	EnableHTTP2           bool
	FastHTTPRequestServer FastHTTPRequestServer
	NetHTTPRequestServer  NetHTTPRequestServer
	EnableHTTP3           bool
	Debug                 bool
	Handler               RequestHandler

	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	// contains filtered or unexported fields
}

func (*Server) AddExtraHeader

func (server *Server) AddExtraHeader(key, value string)

func (*Server) GetExtraHeaders

func (server *Server) GetExtraHeaders() map[string]string

func (*Server) Serve

func (server *Server) Serve()

type Stream

type Stream interface {
	io.Reader
	io.Closer
}

Jump to

Keyboard shortcuts

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