httpserver

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

@Time : 2019-01-19 10:50 @Author : seefan @File : archive.go @Software: microgo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive added in v0.1.1

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

Archive Archive

func (*Archive) After added in v0.1.1

func (a *Archive) After(mid service.Ware, svc ...service.Service)

After set after ware

func (*Archive) Before added in v0.1.1

func (a *Archive) Before(mid service.Ware, svc ...service.Service)

Before set before ware

type HTTPContext

type HTTPContext struct {
	Request  *http.Request
	Response http.ResponseWriter
	// contains filtered or unexported fields
}

HTTPContext context

func (*HTTPContext) Body added in v0.1.5

func (h *HTTPContext) Body() string

Body 获取 request body

func (*HTTPContext) Keys added in v0.1.1

func (h *HTTPContext) Keys() []string

Keys list key

func (*HTTPContext) Set

func (h *HTTPContext) Set(name, value string)

Set set param

func (*HTTPContext) SetForm added in v0.1.1

func (h *HTTPContext) SetForm(forms url.Values)

SetForm Set form param

func (*HTTPContext) Slice added in v0.1.1

func (h *HTTPContext) Slice(name string) []string

Slice get param slice

func (*HTTPContext) String added in v0.1.1

func (h *HTTPContext) String(name string) string

String get string param

func (*HTTPContext) Value added in v0.1.1

func (h *HTTPContext) Value(name string) ctx.Value

Value get param value

type HTTPServer

type HTTPServer struct {
	server.Server

	//Debug output debug info
	Debug bool

	//common prefix
	Prefix string

	//method context
	Context func(*HTTPContext) ctx.Entry
	//Marshal format
	Marshal func(result *ctx.Result) ([]byte, error)
	//result format
	Result func(result *ctx.Result) interface{}
	//error format
	Error func(result *ctx.Result, err error)
	//log
	RuntimeLog func(err error)
	//parse websocket path
	WebSocketPath func(string) (string, string)
	//parse webscoket message
	WebSocketMessage func(string) (map[string]string, error)
	// contains filtered or unexported fields
}

HTTPServer for basic function

func NewHTTPServer

func NewHTTPServer(host string, port int) *HTTPServer

NewHTTPServer create new http server

func (*HTTPServer) Header added in v0.1.1

func (h *HTTPServer) Header(name, value string)

Header Set common header

func (*HTTPServer) Register

func (h *HTTPServer) Register(svc service.Service) *Archive

Register register service

func (*HTTPServer) RegisterAfterWare added in v0.1.1

func (h *HTTPServer) RegisterAfterWare(svc service.Service, md ...service.Ware)

RegisterAfterWare only register ware

func (*HTTPServer) RegisterBeforeWare added in v0.1.1

func (h *HTTPServer) RegisterBeforeWare(svc service.Service, md ...service.Ware)

RegisterBeforeWare only register ware

func (*HTTPServer) SetDocPath added in v0.1.1

func (h *HTTPServer) SetDocPath(path string)

SetDocPath only register ware

func (*HTTPServer) SetStaticPath added in v0.1.1

func (h *HTTPServer) SetStaticPath(path, url string)

SetStaticPath static files

func (*HTTPServer) SetTemplatePath added in v0.1.1

func (h *HTTPServer) SetTemplatePath(path, ext string, cached ...bool) error

SetTemplatePath static files

func (*HTTPServer) SetWebsocketURL added in v0.1.1

func (h *HTTPServer) SetWebsocketURL(url string)

SetWebsocketURL websocket url prefix

func (*HTTPServer) Start

func (h *HTTPServer) Start() (err error)

Start the server

func (*HTTPServer) Stop

func (h *HTTPServer) Stop() error

Stop stop the server

type Method added in v0.1.1

type Method = interface{}

Method method map

type MethodInputPutput added in v0.1.2

type MethodInputPutput = func(entry ctx.Entry) interface{}

//MethodInputPutput method

type MethodNoInputOutput added in v0.1.2

type MethodNoInputOutput = func()

//MethodNotInputOutput no input no output

type MethodOnlyInput added in v0.1.2

type MethodOnlyInput = func(entry ctx.Entry)

//MethodOnlyInput no output

type MethodOnlyOutput added in v0.1.2

type MethodOnlyOutput = func() interface{}

//MethodOnlyOutput no input

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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