Ready to refine the context and router bean.
This commit is contained in:
15
code/core/bean.go
Normal file
15
code/core/bean.go
Normal file
@ -0,0 +1,15 @@
|
||||
package core
|
||||
|
||||
/**
|
||||
* 系统中的Bean接口,即系统中单例模式
|
||||
*/
|
||||
type IBean interface {
|
||||
//初始化方法
|
||||
Init()
|
||||
//系统清理方法
|
||||
Cleanup()
|
||||
//所有配置都加载完成后调用的方法,包括数据库加载完毕
|
||||
Bootstrap()
|
||||
//快速的Panic方法
|
||||
PanicError(err error)
|
||||
}
|
1
code/core/context.go
Normal file
1
code/core/context.go
Normal file
@ -0,0 +1 @@
|
||||
package core
|
11
code/core/controller.go
Normal file
11
code/core/controller.go
Normal file
@ -0,0 +1,11 @@
|
||||
package core
|
||||
|
||||
import "net/http"
|
||||
|
||||
type IController interface {
|
||||
IBean
|
||||
//注册自己固定的路由。
|
||||
RegisterRoutes() map[string]func(writer http.ResponseWriter, request *http.Request)
|
||||
//处理一些特殊的路由。
|
||||
HandleRoutes(writer http.ResponseWriter, request *http.Request) (func(writer http.ResponseWriter, request *http.Request), bool)
|
||||
}
|
7
code/core/global.go
Normal file
7
code/core/global.go
Normal file
@ -0,0 +1,7 @@
|
||||
package core
|
||||
|
||||
//该文件中记录的是应用系统中全局变量。主要有日志LOGGER和上下文CONTEXT
|
||||
|
||||
//日志系统必须高保
|
||||
//全局唯一的日志对象(在main函数中初始化)
|
||||
var LOGGER Logger
|
@ -1,9 +1,5 @@
|
||||
package core
|
||||
|
||||
//日志系统必须高保
|
||||
//全局唯一的日志对象(在main函数中初始化)
|
||||
var LOGGER Logger
|
||||
|
||||
type Logger interface {
|
||||
//处理日志的统一方法。
|
||||
Log(prefix string, format string, v ...interface{})
|
||||
|
Reference in New Issue
Block a user