simpwebserv

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 14 Imported by: 1

README

simpwebserv

一个给go的http服务端框架

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileOverSize = errors.New("File over size")
View Source
var IncompleteFile = errors.New("Incomplete file")
View Source
var IncorrectRequest = errors.New("Incorrect request")

Functions

This section is empty.

Types

type SimpwebservApp

type SimpwebservApp struct {
	Listener                   net.Listener
	UrlMap                     SimpwebservUrlNode
	UseHTTPS                   bool
	HTTPSConfig                *tls.Config
	NotFoundHandler            func(*SimpwebservRequest) *SimpwebservResponse
	InternalServerErrorHandler func(error) *SimpwebservResponse
	DebugMode                  bool
	EnableConsoleLog           bool
}

func App

func App() SimpwebservApp

func (*SimpwebservApp) Register

func (app *SimpwebservApp) Register(function func(*SimpwebservRequest) *SimpwebservResponse, path string)

func (*SimpwebservApp) RegisterInternalServerErrorFunction added in v1.5.0

func (app *SimpwebservApp) RegisterInternalServerErrorFunction(function func(error) *SimpwebservResponse)

func (*SimpwebservApp) RegisterNotFoundFunction added in v1.5.0

func (app *SimpwebservApp) RegisterNotFoundFunction(function func(*SimpwebservRequest) *SimpwebservResponse)

func (*SimpwebservApp) Run

func (app *SimpwebservApp) Run(host string, port uint16)

func (*SimpwebservApp) SetDebugMode added in v1.5.0

func (app *SimpwebservApp) SetDebugMode(onoff bool)

func (*SimpwebservApp) SetEnableConsoleLog added in v1.6.0

func (app *SimpwebservApp) SetEnableConsoleLog(onoff bool)

func (*SimpwebservApp) SetHTTPS added in v1.4.0

func (app *SimpwebservApp) SetHTTPS(pemPath string, keyPath string) error

type SimpwebservRequest

type SimpwebservRequest struct {
	Method   string
	Path     string
	PurePath string
	Protocol string
	Host     string
	Header   map[string]string
	Conn     net.Conn
	// contains filtered or unexported fields
}

func (*SimpwebservRequest) DecodeCookie added in v1.3.0

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

func (*SimpwebservRequest) DecodeGETRequest added in v1.3.0

func (request *SimpwebservRequest) DecodeGETRequest() map[string]string

func (*SimpwebservRequest) DecodePOSTFormRequest added in v1.3.0

func (request *SimpwebservRequest) DecodePOSTFormRequest() map[string]string

func (*SimpwebservRequest) RecvFile added in v1.3.0

func (request *SimpwebservRequest) RecvFile(storePath string, name string, maxSize int) error

type SimpwebservResponse

type SimpwebservResponse struct {
	Protocol      string
	Code          string
	CodeName      string
	Header        map[string]string
	Body          *bytes.Buffer
	ToDoCommand   string
	SetCookieList []string
}

func BuildBasicResponse

func BuildBasicResponse() *SimpwebservResponse

func BuildInternalServerErrorResponse added in v1.5.0

func BuildInternalServerErrorResponse() *SimpwebservResponse

func BuildJumpResponse added in v1.1.0

func BuildJumpResponse(target string) *SimpwebservResponse

func BuildNotFoundResponse

func BuildNotFoundResponse() *SimpwebservResponse

func SendFile added in v1.2.0

func SendFile(request *SimpwebservRequest, contentType string, filePath string, fileName string) *SimpwebservResponse

func SendStaticFile added in v1.1.0

func SendStaticFile(path string, contentType string) *SimpwebservResponse

func (*SimpwebservResponse) SetCookie added in v1.3.0

func (response *SimpwebservResponse) SetCookie(cookieKey string, cookieValue string, expiresTime string, domain string, path string, secure bool, httpOnly bool)

type SimpwebservUrlNode

type SimpwebservUrlNode struct {
	Name        string
	NextLayer   *list.List
	IncludeBack bool
	Function    func(*SimpwebservRequest) *SimpwebservResponse
}

Jump to

Keyboard shortcuts

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