server

package
v0.0.0-...-4e24f74 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheHtmlTemplates

func CacheHtmlTemplates()

func HttpServer

func HttpServer(ch chan int)

func Route

func Route(url string, cb func(Context), authorize bool)

url接口地址 controller 回调函数 Context 入参上下文 authorize 是否需要授权访问 true=授权之后才能访问 false=不需要授权

Types

type Context

type Context interface {
	StateCode(code int)
	Result(code int, data interface{}) Result
	Response() *Response
	Request() *http.Request
	GetBody() string
	Param(key string) string
	Form() url.Values
	PostForm() url.Values
	GetFormFile(key string) (multipart.File, *multipart.FileHeader, error)
	Cookie() Cookie
	Session() Session
	LoginAuth()
	TplHtml(tplName string) *Html
	// contains filtered or unexported methods
}

type Controller

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

func (*Controller) Cookie

func (m *Controller) Cookie() Cookie

func (*Controller) Form

func (m *Controller) Form() url.Values

func (*Controller) GetBody

func (m *Controller) GetBody() string

func (*Controller) GetFormFile

func (m *Controller) GetFormFile(key string) (multipart.File, *multipart.FileHeader, error)

func (*Controller) LoginAuth

func (m *Controller) LoginAuth()

登录或授权成功后调用,设置已授权

func (*Controller) Param

func (m *Controller) Param(key string) string

func (*Controller) PostForm

func (m *Controller) PostForm() url.Values

func (*Controller) Request

func (m *Controller) Request() *http.Request

func (*Controller) Response

func (m *Controller) Response() *Response

func (*Controller) Result

func (m *Controller) Result(code int, data interface{}) Result

func (*Controller) Session

func (m *Controller) Session() Session

func (*Controller) SetCookie

func (m *Controller) SetCookie(key, value string)

func (*Controller) StateCode

func (m *Controller) StateCode(stateCode int)

func (*Controller) TplHtml

func (m *Controller) TplHtml(tplName string) *Html
type Cookie interface {
	Set(key string, value string)
	Get(key string) string
}

type Html

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

func (*Html) Data

func (m *Html) Data(data interface{})

type Response

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

func (*Response) Write

func (m *Response) Write(data []byte)

type Result

type Result interface {
	Success()
	Fail()
}

type Session

type Session interface {
	Set(key string, value interface{})
	Get(key string) interface{}
	Id() string
	// contains filtered or unexported methods
}

func GetSession

func GetSession(sid string) Session

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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