go_boot

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

Go-BOOT

介绍

go语言快速集成web框架

软件架构

基于原生http构建,具备网站及接口开发相关基础功能

使用说明
go get  gitee.com/lshsuper/go-boot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(cnf ServerConf) *server

Types

type Action

type Action func(ctx *Context)

func (Action) ServeHTTP

func (act Action) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP 服务

type BaseController

type BaseController struct {
}

BaseController 控制器基础实现

func (*BaseController) After

func (b *BaseController) After(ctx *Context) error

func (*BaseController) Before

func (b *BaseController) Before(ctx *Context) error

func (*BaseController) Ignore

func (b *BaseController) Ignore() (lst []string)

func (*BaseController) Prefix

func (b *BaseController) Prefix() string

func (*BaseController) Recover

func (b *BaseController) Recover(ctx *Context, err interface{})

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func (*Context) ActionName added in v1.0.5

func (ctx *Context) ActionName() string

func (*Context) ControllerName added in v1.0.5

func (ctx *Context) ControllerName() string

func (*Context) FFloat64 added in v1.0.5

func (ctx *Context) FFloat64(key string, def float64) float64

FFloat64 获取Float64参数

func (*Context) FInt added in v1.0.5

func (ctx *Context) FInt(key string, def int) int

FInt 获取int参数

func (*Context) FString added in v1.0.5

func (ctx *Context) FString(key string, def string) string

FString 获取字符串类型

func (*Context) GFloat64 added in v1.0.5

func (ctx *Context) GFloat64(key string, def float64) float64

GFloat64 获取Float64参数

func (*Context) GInt added in v1.0.5

func (ctx *Context) GInt(key string, def int) int

GInt 获取int参数

func (*Context) GString added in v1.0.5

func (ctx *Context) GString(key string, def string) string

GString 获取字符串类型

func (*Context) Json

func (ctx *Context) Json(data interface{})

func (*Context) Proxy added in v1.0.5

func (ctx *Context) Proxy(target *url.URL)

Proxy 代理转换 target ->来源于注册中心or配置好的地址

func (*Context) Req

func (ctx *Context) Req() *http.Request

Req 请求体

func (*Context) Res

func (ctx *Context) Res() http.ResponseWriter

Res 响应体

func (*Context) Set

func (ctx *Context) Set(key interface{}, val interface{})

func (*Context) Value

func (ctx *Context) Value(key interface{}) (val interface{})

type Controller

type Controller interface {
	//Before Action前置操作(可以做相关逻辑:如跨域等处理)
	Before(ctx *Context) error
	//After Action后置操作(可以做相关逻辑:如跨域等处理)
	After(ctx *Context) error
	//Prefix Action接口前缀(分组名)
	Prefix() string
	//Ignore 忽略的Action
	Ignore() []string
	//Recover 异常抓取操作
	Recover(ctx *Context, err interface{})
}

type ServerConf added in v1.0.1

type ServerConf struct {
	Boot           string
	Mode           ServerMode
	IgnorePathCase bool
	ControllerPath string
}

type ServerMode added in v1.0.1

type ServerMode string

ServerMode 服务启动模式

const (
	DEBUG   ServerMode = "debug"
	RELEASE ServerMode = "release"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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