simpwebserv

package module
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 16 Imported by: 1

README

simpwebserv

一个给go的http服务端框架

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBufferTooBig            = errors.New("buffer too big")
	ErrRequirementNotSatisfied = errors.New("requirement not satisfied")
)

Functions

func PanicTrace added in v1.7.1

func PanicTrace() []byte

Types

type AppStruct added in v1.7.1

type AppStruct struct {
	HTTPSConfig *tls.Config
	// contains filtered or unexported fields
}

func App

func App() *AppStruct

func (*AppStruct) Register added in v1.7.1

func (app *AppStruct) Register(function func(*Request) *Response, path string, includeBack bool)

func (*AppStruct) Run added in v1.7.1

func (app *AppStruct) Run(config Config)

func (*AppStruct) SetDebugMode added in v1.7.1

func (app *AppStruct) SetDebugMode(onoff bool)

func (*AppStruct) SetEnableConsoleLog added in v1.7.1

func (app *AppStruct) SetEnableConsoleLog(onoff bool)

func (*AppStruct) SetEnableKeepAlive added in v1.7.1

func (app *AppStruct) SetEnableKeepAlive(onoff bool)

func (*AppStruct) SetKeepAliveTimeout added in v1.7.1

func (app *AppStruct) SetKeepAliveTimeout(timeout uint64)

func (*AppStruct) SetTls added in v1.7.1

func (app *AppStruct) SetTls(pemPath string, keyPath string) error

type Config added in v1.7.1

type Config struct {
	Host                 string
	Port                 uint16
	UseTls               bool
	DebugMode            bool
	DisableConsoleLog    bool
	DisableKeepAlive     bool
	KeepAliveTimeout     time.Duration
	TlsPemPath           string
	TlsKeyPath           string
	MultiThreadAcceptNum uint16
}

type Request added in v1.7.1

type Request struct {
	Method       string
	Path         string
	UrlParameter string
	Protocol     string
	Host         string
	Header       map[string]string
	// contains filtered or unexported fields
}

func (*Request) ConnRead added in v1.7.1

func (request *Request) ConnRead(buf []byte) (int, error)

func (*Request) ConnReadUntil added in v1.7.1

func (request *Request) ConnReadUntil(spliter []byte, writer io.Writer, maxSize uint64) error

func (*Request) ConnWrite added in v1.7.1

func (request *Request) ConnWrite(buf []byte) (int, error)

func (*Request) DecodeCookie added in v1.7.1

func (request *Request) DecodeCookie() map[string]string

func (*Request) DecodeFormUrlEncoded added in v1.7.1

func (request *Request) DecodeFormUrlEncoded() (map[string]string, error)

func (*Request) DecodeUrlParameter added in v1.7.1

func (request *Request) DecodeUrlParameter() map[string]string

func (*Request) RecvFile added in v1.7.1

func (request *Request) RecvFile(storePath string, filename string, maxSize uint64) error

func (*Request) SendFile added in v1.7.1

func (request *Request) SendFile(response *Response, path string, filename string)

func (*Request) SendHeader added in v1.7.1

func (request *Request) SendHeader(response *Response)

type Response added in v1.7.1

type Response struct {
	Protocol      string
	Code          string
	CodeName      string
	Header        map[string]string
	Body          *bytes.Buffer
	SetCookieList []string
	// contains filtered or unexported fields
}

func Build404DefaultResponse added in v1.7.1

func Build404DefaultResponse() *Response

func Build404Response added in v1.7.1

func Build404Response() *Response

func Build500DefaultResponse added in v1.7.1

func Build500DefaultResponse() *Response

func BuildBasicResponse

func BuildBasicResponse() *Response

func BuildStaticFileResponse added in v1.7.1

func BuildStaticFileResponse(path string, contentType string) *Response

type UrlNode added in v1.7.1

type UrlNode struct {
	NextLayer   map[string]*UrlNode
	IncludeBack bool
	Function    func(*Request) *Response
}

Jump to

Keyboard shortcuts

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