Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
eudore committed Oct 31, 2022
1 parent b80422e commit de9fd1e
Show file tree
Hide file tree
Showing 86 changed files with 5,428 additions and 5,324 deletions.
23 changes: 17 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Change Log

Next
- Client 优化api
- policy 定义http控制器
- component 优化尝试移除
setIntField set Duration type
middleware/cache 不同accept会导致数据格式不同

2022年4月30日
Next
- Database 实现

[2022年10月31日]
- App 优化运行输出日志
- Client 完整重构
- Logger 修复Sync方法,更新其他组件日志
- Config 合并实现方法
- Render/BindProtobuf 无需proto文件进行编码
- NewContextMessage 新增函数返回请求上下文消息,复用message。
- middleware/gzip 使用自定义压缩函数,可以使用br压缩。
- middleware/look 使用自定义data获取函数。

[2022年4月30日](https://github.com/eudore/eudore/tree/b80422e67f5c9907967e36e577d23220793a6c9c)
- App和Context 生命周期管理
- DataHandlerFunc 合并Bind Validate Filte Render
- Client 移入App组合
Expand All @@ -14,7 +25,7 @@ Next
- example 重写单位测试,不将example转换成测试文件。


2021年10月31日
[2021年10月31日](https://github.com/eudore/eudore/tree/46e8a335592dfd8b498d5f681f2f385204b80a1a)
- RouterStd 添加others方法,清理deleteRoute参数。
- ControllerAutoRoute 简化调整规则。
- middleware/look 解析Accept Header为format值,模板内容优化。
Expand Down
19 changes: 12 additions & 7 deletions _example/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# example

本部分为演示例子目录功能导航,保存eudore、middleware、policy、component实现的功能演示,eudore只有没实现的功能,没有无法实现的功能,详细文档查看[wiki文档](https://github.com/eudore/eudore/wiki)或者[源码](https://github.com/eudore/eudore),仅保证eudore和middleware两个库的稳定性,component系列库可能重构或移除,Alpha的演示库不稳定。
本部分为演示例子目录功能导航,保存eudore、middleware、policy实现的功能演示,eudore只有没实现的功能,没有无法实现的功能,详细文档查看[wiki文档](https://github.com/eudore/eudore/wiki)或者[源码](https://github.com/eudore/eudore),仅保证eudore和middleware两个库的稳定性,Alpha的演示库不稳定。

单元测试: `CGO_ENABLED=1 go test -v -timeout=2m -race -cover -coverpkg='github.com/eudore/eudore,github.com/eudore/eudore/middleware,github.com/eudore/eudore/policy' *_test.go
`

go version go1.18.1 linux/amd64 coverage: 100.0% of statements in github.com/eudore/eudore, github.com/eudore/eudore/middleware, github.com/eudore/eudore/policy
go version go1.18.7 linux/amd64 coverage: 100.0% of statements in github.com/eudore/eudore, github.com/eudore/eudore/middleware, github.com/eudore/eudore/policy

因版本变化未全部更新。

- Application
- [New](appNew.go)
Expand Down Expand Up @@ -40,7 +42,6 @@ go version go1.18.1 linux/amd64 coverage: 100.0% of statements in github.com/eud
- [服务监听](serverListen.go)
- [使用https](serverHttps.go)
- [双向https](serverMutualTLS.go)
- [eudore server启动服务](serverEudore.go)
- [fastcgi启动服务](serverFcgi.go)
- Router
- [组路由](routerGroup.go)
Expand All @@ -52,6 +53,7 @@ go version go1.18.1 linux/amd64 coverage: 100.0% of statements in github.com/eud
- [Host路由器](routerHost.go)
- [路由器注册调试](routerDebug.go)
- [路由器注册移除](routerDelete.go)
- [路由器核心简化](routerCore.go)
- [radix树](routerRadix.go)
- Context
- [Request Info](contextRequestInfo.go)
Expand Down Expand Up @@ -83,7 +85,7 @@ go version go1.18.1 linux/amd64 coverage: 100.0% of statements in github.com/eud
- [路径匹配扩展](handlerTree.go)
- [分级匹配扩展](handlerWarp.go)
- [Rpc式请求](handlerRpc.go)
- [map Rpc式请求](handlerRpcMap.go)
- [Rpc式map请求](handlerRpcMap.go)
- [使用embed](handlerEmbed.go)
- [使用jwt](handlerJwt.go)
- Controller
Expand Down Expand Up @@ -141,14 +143,17 @@ go version go1.18.1 linux/amd64 coverage: 100.0% of statements in github.com/eud
- tool
- [转换对象成map](toolConvertMap.go)
- [对象转换](toolConvertTo.go)
- [解析sql rows绑定](toolConvertRows.go)
- [基于路径读写对象](toolGetSet.go)
- [结构体和变量校验](toolValidate.go)
- net/http
- [中间件 黑名单](nethttpBlack.go)
- [中间件 路径重写](nethttpRewrite.go)
- [中间件 BasicAuth](nethttpBasicAuth.go)
- [中间件 限流](nethttpRateRequest.go)
- other
- [反向代理](otherProxy.go)
- [隧道代理](otherTunnel.go)
- [隧道代理](otherTunnel.go)
- [http客户端简化实现](otherHttpClient.go)
- [http服务端简化实现](otherHttpServer.go)
- [http服务端简化](otherHttpServer2.go)


32 changes: 25 additions & 7 deletions _example/appCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,40 @@ command包解析启动命令,支持start、daemon、status、stop、restart五
*/

import (
"context"
"time"

"github.com/eudore/eudore"
"github.com/eudore/eudore/component/command"
"github.com/eudore/eudore/daemon"
)

func main() {
app := eudore.NewApp()
app.SetValue(eudore.ContextKeyLogger, eudore.NewLoggerInit())

app.ParseOption(append(eudore.DefaultConfigAllParseFunc, daemon.NewParseCommand(app), NewParseLogger(app)))
app.SetValue(eudore.ContextKeyError, app.Parse())
app.SetValue(eudore.ContextKeyError, command.Init(app))
if app.Err() != nil {
app.Run()
return
}
app.GetFunc("/*", func(ctx eudore.Context) {
ctx.WriteString("hello eudore")
ctx.WriteString("server daemon")
})

go func() {
select {
case <-app.Done():
case <-time.After(10 * time.Second):
app.CancelFunc()
}
}()
app.Listen(":8088")
app.Run()
}

func NewParseLogger(app *eudore.App) eudore.ConfigParseFunc {
return func(ctx context.Context, cnf eudore.Config) error {
app.SetValue(eudore.ContextKeyLogger, eudore.NewLoggerStd(&eudore.LoggerStdConfig{
Std: true,
Path: "/tmp/daemon.log",
}))
return nil
}
}
32 changes: 29 additions & 3 deletions _example/appDaemon.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
package main

/*
command包可以通过Daemon()函数后台启动程序,也可以通过命令解析启动程序。
通过Daemon()函数后台启动程序,也可以通过命令解析启动程序。
当第一次启动时,使用os.Exec执行启动命令后台启动进程、关闭进程并附加环境变量,第二次启动时检测到环境变量即为后台启动,会忽略后台启动逻辑。然后执行正常启动。
该组件不支持win系统。
*/

import (
"fmt"
"os"
"os/exec"
"time"

"github.com/eudore/eudore"
"github.com/eudore/eudore/component/command"
)

func main() {
command.Daemon()
Daemon()

app := eudore.NewApp()
app.GetFunc("/*", func(ctx eudore.Context) {
ctx.WriteString("server daemon")
})

go func() {
select {
case <-app.Done():
case <-time.After(10 * time.Second):
app.CancelFunc()
}
}()
app.Listen(":8088")
app.Run()
}

// Daemon 函数直接后台启动程序。
func Daemon(envs ...string) {
if eudore.GetStringBool(os.Getenv(eudore.EnvEudoreIsDaemon)) {
return
}

cmd := exec.Command(os.Args[0], os.Args[1:]...)
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%d", eudore.EnvEudoreIsDaemon, 1))
cmd.Env = append(cmd.Env, envs...)
cmd.Stdout = os.Stdout
cmd.Start()
os.Exit(0)
}
Loading

0 comments on commit de9fd1e

Please sign in to comment.