kmgControllerRunner

package
v0.0.0-...-05317bf Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnterPointApiName = ""

EnterPointApiName 最前面不要加 /?n=

View Source
var HttpProcessorList = []HttpProcessor{
	PanicHandler,
	Dispatcher,
}

Functions

func AddHTTPBasicAuth

func AddHTTPBasicAuth(username, password string)

* Example: 在 kmgControllerRunner.StartServerCommand() 前调用 needAuthFilter 返回 true 表示需要验证身份 下面这个例子是:只有在访问前缀是 "/?n=Admin.User.Info" 时才验证身份

kmgControllerRunner.AddHTTPBasicAuthenticationDispatcher("UserName", "Password", func(ctx *kmgHttp.Context) bool {
	return strings.HasPrefix(ctx.GetRequestUrl(), "/?n=Admin.User.Info")
})

func AddHTTPBasicAuthWithFilter

func AddHTTPBasicAuthWithFilter(username, password string, needAuthFilter func(ctx *kmgHttp.Context) bool)

func ContextHandle

func ContextHandle(ctx *kmgHttp.Context)

func Dispatcher

func Dispatcher(ctx *kmgHttp.Context, processorList []HttpProcessor)

func GetControllerNameList

func GetControllerNameList() []string

func HttpHandlerFunc

func HttpHandlerFunc(w http.ResponseWriter, req *http.Request)

httpHandler

func PanicHandler

func PanicHandler(ctx *kmgHttp.Context, processorList []HttpProcessor)

func RegisterController

func RegisterController(obj interface{})

注册controller,请先注册后使用,该函数不能并发调用,不能在http开始处理之后再注册(data race问题) 允许重复注册.

func RegisterControllerFunc

func RegisterControllerFunc(name string, f func(ctx *kmgHttp.Context))

此处可以随意定义Api的名称,用来解决调用者的名称向前兼容问题. 普通情况下可以使用 RegisterController,减少信息重复.

func RequestLogger

func RequestLogger(ctx *kmgHttp.Context, processorList []HttpProcessor)

默认不用这个,容易搞的测试里面到处都是log. TODO 静态文件的log问题 TODO 尝试搞出更好用的log系统.

func StartHttpServer

func StartHttpServer(addr string)

func StartServer

func StartServer(sReq ServerRequest)

Deprecated

func StartServerAsync

func StartServerAsync(serverAddress string) (closer func() error)

func StartServerCommand

func StartServerCommand()

以命令行方式运行应用.这个函数会阻塞执行. http方式运行 ./MainApp -http=:80 https 方式 加http跳转运行 (必须绑一个域名,如果有更复杂的需求,此处无法完成)

./MainApp -https=:443 -http=:80 -type=Both -certFile=xxx.crt -keyFile=xxx.key domain=xxx.com

Types

type HttpProcessor

type HttpProcessor func(ctx *kmgHttp.Context, processorList []HttpProcessor)

type ServerRequest

type ServerRequest struct {
	HttpAddr          string
	HttpsAddr         string
	HttpsCertFilePath string
	HttpsKeyFilePath  string
	Domain            string
	Type              ServerType
}

type ServerType

type ServerType string
const (
	ServerTypeHttp ServerType = "Http" //只有http
	ServerTypeBoth ServerType = "Both" //http跳转到https
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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