├── README.md
├── performance
├── docker-entrypoint.sh
├── Dockerfile
└── main.go
├── static
├── cup-small.png
└── main.go
├── .travis.yml
├── configset
├── userconf.xml
└── main.go
├── uploadfile
├── fileupload.html
├── filesupload.html
└── main.go
├── render
├── testview.html
└── main.go
├── render_pango2
├── testview.html
└── main.go
├── helloworld
└── main.go
├── gzip
└── main.go
├── main_test.go
├── controller
└── main.go
├── exception
└── main.go
├── cookie
└── main.go
├── httpcontext
└── main.go
├── tls
└── main.go
├── router
└── main.go
├── appcontext
└── main.go
├── file
└── main.go
├── bind
└── main.go
├── cache
└── main.go
├── config
├── dotweb.conf
├── main.go
└── dotweb.json.conf
├── session
└── main.go
├── middleware
└── main.go
├── httpmodule
└── main.go
├── logger
└── main.go
└── main.go
/README.md:
--------------------------------------------------------------------------------
1 | # dotweb-example
2 | the example for dotweb
3 |
--------------------------------------------------------------------------------
/performance/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | cd /home
3 | /home/performance
4 |
--------------------------------------------------------------------------------
/static/cup-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devfeel/dotweb-example/HEAD/static/cup-small.png
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | sudo: required
3 |
4 | go:
5 | - 1.8
6 |
7 | env:
8 | - GO15VENDOREXPERIMENT="1"
9 |
10 | before_install:
11 | - Project=devfeel
12 |
13 | script:
14 | - go build -o "$Project"
--------------------------------------------------------------------------------
/configset/userconf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/uploadfile/fileupload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 文件上传
5 |
6 |
7 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/render/testview.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | load common template
5 |
6 |
7 |
8 | {{.data}}
9 |
10 | User Profile:
11 |
12 | UserName => {{.user.UserName}}
13 |
14 | Sex => {{.user.Sex}}
15 |
16 |
17 | Books:
18 |
19 | {{range .Books}}
20 | BookName => {{.Name}}; Size => {{.Size}}
21 |
22 | {{end}}
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/performance/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM docker.io/golang:alpine
2 | MAINTAINER devfeel
3 |
4 | # 创建基础目录
5 | RUN mkdir -p /home
6 |
7 | # 拷贝运行文件及配置文件
8 | COPY performance /home/performance
9 |
10 | # 拷贝启动脚本
11 | COPY docker-entrypoint.sh /home/docker-entrypoint.sh
12 |
13 | # 暴露端口
14 | EXPOSE 80 81 8080
15 |
16 | # 赋权
17 | RUN chmod +x /home/performance
18 | RUN chmod +x /home/docker-entrypoint.sh
19 |
20 | ENTRYPOINT ["/home/docker-entrypoint.sh"]
--------------------------------------------------------------------------------
/render_pango2/testview.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | load common template
5 |
6 |
7 |
8 | {{data}}
9 |
10 | User Profile:
11 |
12 | UserName => {{user.UserName}}
13 |
14 | Sex => {{user.Sex}}
15 |
16 |
17 | Books:
18 |
19 | {% for book in Books %}
20 | BookName => {{ book.Name }}; Size => {{ book.Size }}
21 |
22 | {% endfor %}
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/uploadfile/filesupload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 文件上传
5 |
6 |
7 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/helloworld/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | )
7 |
8 | func main() {
9 | //初始化DotServer
10 | app := dotweb.Classic(dotweb.DefaultLogPath)
11 |
12 | //开启debug模式
13 | app.SetDevelopmentMode()
14 |
15 | //设置路由
16 | InitRoute(app.HttpServer)
17 |
18 | //开始服务
19 | port := 8080
20 | err := app.StartServer(port)
21 | fmt.Println("dotweb.StartServer error => ", err)
22 | }
23 |
24 | func Hello(ctx dotweb.Context) error {
25 | ctx.WriteString("hello world!")
26 | return nil
27 | }
28 |
29 | func Do() (string, error){
30 | return "", nil
31 | }
32 |
33 | func InitRoute(server *dotweb.HttpServer) {
34 | server.Router().GET("/hello", Hello)
35 | }
36 |
--------------------------------------------------------------------------------
/gzip/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | _ "github.com/devfeel/middleware/gzip"
7 | )
8 |
9 | func main() {
10 | //初始化DotServer
11 | app := dotweb.New()
12 |
13 | //开启debug模式
14 | app.SetDevelopmentMode()
15 |
16 | //开启GZIP模式
17 | //1、集成方式
18 | app.HttpServer.SetEnabledGzip(true)
19 | //2、中间件方式
20 | //app.Use(gzip.Middleware(gzip.NewConfig().UseDefault()))
21 |
22 | //设置路由
23 | InitRoute(app.HttpServer)
24 |
25 | //开始服务
26 | port := 8080
27 | err := app.StartServer(port)
28 | fmt.Println("dotweb.StartServer error => ", err)
29 | }
30 |
31 | func Hello(ctx dotweb.Context) error {
32 | ctx.WriteString("hello world!")
33 | return nil
34 | }
35 |
36 | func InitRoute(server *dotweb.HttpServer) {
37 | server.Router().GET("/hello", Hello)
38 | }
39 |
--------------------------------------------------------------------------------
/main_test.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "testing"
5 | "strings"
6 | "fmt"
7 | )
8 |
9 | func TestHostParse(t *testing.T){
10 | host := "www.dev.com:2"
11 | if strings.Index(host, ":") >0{
12 | fmt.Println(strings.Split(host, ":")[0])
13 | fmt.Println(host[0:strings.Index(host, ":")])
14 | }else{
15 | fmt.Println(host)
16 | }
17 | }
18 |
19 | func BenchmarkTestHostParse1(b *testing.B) {
20 | host := "www.dev.com:2"
21 | for i := 0; i < b.N; i++ {
22 | _ = strings.Index(host, ":")
23 | }
24 | }
25 |
26 | func BenchmarkTestHostParse2(b *testing.B) {
27 | host := "www.dev.com:2"
28 | for i := 0; i < b.N; i++ {
29 | _ = strings.Split(host, ":")[0]
30 | }
31 | }
32 |
33 | func BenchmarkTestHostParse3(b *testing.B) {
34 | host := "www.dev.com:2"
35 | for i := 0; i < b.N; i++ {
36 | s := host[0:strings.Index(host, ":")]
37 | _ = s
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/controller/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "strconv"
7 | )
8 |
9 | func main() {
10 | //初始化DotServer
11 | app := dotweb.New()
12 |
13 | //设置路由
14 | InitRoute(app.HttpServer)
15 |
16 | // 开始服务
17 | port := 8080
18 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
19 | err := app.StartServer(port)
20 | fmt.Println("dotweb.StartServer error => ", err)
21 | }
22 |
23 | type TestController struct {
24 | }
25 |
26 | func (c *TestController) Index(ctx dotweb.Context) error {
27 | return ctx.WriteString("index - TestController.Index")
28 | }
29 |
30 | func (c *TestController) Group(ctx dotweb.Context) error {
31 | return ctx.WriteString("group - " + ctx.Request().Url())
32 | }
33 |
34 | func InitRoute(server *dotweb.HttpServer) {
35 | controller := &TestController{}
36 | server.Router().GET("/", controller.Index)
37 | g := server.Group("/g")
38 | g.GET("/1", controller.Group)
39 | }
40 |
--------------------------------------------------------------------------------
/exception/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "errors"
5 | "fmt"
6 | "github.com/devfeel/dotweb"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | //初始化App必要设置
15 | InitApp(app)
16 |
17 | //设置路由
18 | InitRoute(app.HttpServer)
19 |
20 | // 开始服务
21 | port := 8080
22 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
23 | err := app.StartServer(port)
24 | fmt.Println("dotweb.StartServer error => ", err)
25 | }
26 |
27 | func PanicError(ctx dotweb.Context) error {
28 | panic("my panic error!")
29 | }
30 |
31 | func ReturnError(ctx dotweb.Context) error {
32 | return errors.New("return new error")
33 | }
34 |
35 | // InitRoute init routes
36 | func InitRoute(server *dotweb.HttpServer) {
37 | server.Router().GET("/panic", PanicError)
38 | server.Router().GET("/return", ReturnError)
39 | }
40 |
41 | // InitApp init app's setting
42 | func InitApp(app *dotweb.DotWeb) {
43 | //设置自定义异常处理接口
44 | app.SetExceptionHandle(func(ctx dotweb.Context, err error) {
45 | //TODO:you can use your owner logging error message
46 | ctx.WriteString("oh, 系统出错了! ", err.Error())
47 | })
48 | }
49 |
--------------------------------------------------------------------------------
/configset/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/config"
7 | "github.com/devfeel/dotweb/framework/file"
8 | "strconv"
9 | )
10 |
11 | func main() {
12 | //初始化DotServer
13 | app := dotweb.New()
14 |
15 | //设置dotserver日志目录
16 | app.SetLogPath(file.GetCurrentDirectory())
17 |
18 | app.SetDevelopmentMode()
19 |
20 | app.HttpServer.SetEnabledIgnoreFavicon(true)
21 |
22 | //引入自定义ConfigSet
23 | err := app.Config.IncludeConfigSet("d:/gotmp/userconf.xml", config.ConfigType_XML)
24 | if err != nil {
25 | fmt.Println(err.Error())
26 | return
27 | }
28 |
29 | //设置路由
30 | InitRoute(app.HttpServer)
31 |
32 | // 开始服务
33 | port := 8080
34 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
35 | err = app.StartServer(port)
36 | fmt.Println("dotweb.StartServer error => ", err)
37 | }
38 |
39 | func ConfigSet(ctx dotweb.Context) error {
40 | vkey1 := ctx.ConfigSet().GetString("set1")
41 | vkey2 := ctx.ConfigSet().GetString("set2")
42 | ctx.WriteString(ctx.Request().Path(), "key1=", vkey1, "key2=", vkey2)
43 | return ctx.WriteString("\r\n")
44 | }
45 |
46 | func InitRoute(server *dotweb.HttpServer) {
47 | server.GET("/c", ConfigSet)
48 | }
49 |
--------------------------------------------------------------------------------
/cookie/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "net/http"
7 | "net/url"
8 | "strconv"
9 | )
10 |
11 | func main() {
12 | //初始化DotServer
13 | app := dotweb.New()
14 |
15 | //设置路由
16 | InitRoute(app.HttpServer)
17 |
18 |
19 | // 开始服务
20 | port := 8080
21 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
22 | err := app.StartServer(port)
23 | fmt.Println("dotweb.StartServer error => ", err)
24 | }
25 |
26 | type UserInfo struct {
27 | UserName string
28 | NickName string
29 | }
30 |
31 | func One(ctx dotweb.Context) error {
32 | ctx.SetCookieValue("dotweb-test", "SetCookieValue", 1000)
33 | fmt.Println("One ", "dotweb")
34 | return ctx.WriteString("One - set cookie value")
35 | }
36 |
37 | func Two(ctx dotweb.Context) error {
38 | val, err := ctx.ReadCookie("dotweb-test")
39 | fmt.Println("begin remove ", val, err)
40 | return ctx.WriteString("Two - cookie =>", val, err)
41 | }
42 |
43 | func Three(ctx dotweb.Context) error {
44 | ctx.SetCookie(&http.Cookie{Name: "dotweb-test", Value: url.QueryEscape("SetCookie"), MaxAge: 1000})
45 | fmt.Println("Three ", "dotweb")
46 | return ctx.WriteString("Three - set cookie")
47 | }
48 |
49 | func InitRoute(server *dotweb.HttpServer) {
50 | server.Router().GET("/1", One)
51 | server.Router().GET("/2", Two)
52 | server.Router().GET("/3", Three)
53 | }
54 |
--------------------------------------------------------------------------------
/httpcontext/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "net/http"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | //设置gzip开关
15 | app.HttpServer.SetEnabledGzip(true)
16 |
17 | app.SetDevelopmentMode()
18 |
19 | //设置路由
20 | InitRoute(app.HttpServer)
21 |
22 | // 开始服务
23 | port := 8080
24 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
25 | err := app.StartServer(port)
26 | fmt.Println("dotweb.StartServer error => ", err)
27 | }
28 |
29 | func WriteString(ctx dotweb.Context) error {
30 | ctx.WriteString("test write string")
31 | return nil
32 | }
33 |
34 | func WriteJson(ctx dotweb.Context) error {
35 | type UserInfo struct {
36 | Name string
37 | Age int
38 | Sex bool
39 | }
40 | u := &UserInfo{
41 | Name: "dotweb lover",
42 | Age: 18,
43 | Sex: true,
44 | }
45 | ctx.WriteJson(u)
46 | return nil
47 | }
48 |
49 | func WriteJsonC(ctx dotweb.Context) error {
50 | type UserInfo struct {
51 | Name string
52 | Age int
53 | Sex bool
54 | }
55 | u := &UserInfo{
56 | Name: "dotweb lover",
57 | Age: 18,
58 | Sex: true,
59 | }
60 | ctx.WriteJsonC(http.StatusOK, u)
61 | return nil
62 | }
63 |
64 | func InitRoute(server *dotweb.HttpServer) {
65 | server.Router().GET("/string", WriteString)
66 | server.Router().POST("/json", WriteJson)
67 | server.Router().POST("/jsonc", WriteJsonC)
68 | }
69 |
--------------------------------------------------------------------------------
/tls/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/exception"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 |
12 | defer func() {
13 | var errmsg string
14 | if err := recover(); err != nil {
15 | errmsg = exception.CatchError("main", dotweb.LogTarget_HttpServer, err)
16 | fmt.Println("main error : ", errmsg)
17 | }
18 | }()
19 |
20 | //初始化DotServer
21 | app := dotweb.New()
22 |
23 | //设置dotserver日志目录
24 | //如果不设置,默认不启用,且默认为当前目录
25 | app.SetEnabledLog(true)
26 |
27 | //开启development模式
28 | app.SetDevelopmentMode()
29 |
30 | //设置路由
31 | InitRoute(app.HttpServer)
32 |
33 | //启动 监控服务
34 | app.SetPProfConfig(true, 8081)
35 |
36 | //设置TLS
37 | app.HttpServer.SetEnabledTLS(true, "D:/gotmp/domain-web.pem", "D:/gotmp/domain.key")
38 |
39 | // 开始服务
40 | port := 8080
41 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
42 | err := app.StartServer(port)
43 | fmt.Println("dotweb.StartServer error => ", err)
44 | }
45 |
46 | // Index index handler
47 | func Index(ctx dotweb.Context) error {
48 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
49 | ctx.WriteString(ctx.Request().URL.Path)
50 | //_, err := ctx.WriteStringC(201, "index => ", ctx.RemoteIP(), "我是首页")
51 | return nil
52 | }
53 |
54 | // InitRoute init http server routers
55 | func InitRoute(server *dotweb.HttpServer) {
56 | server.GET("/", Index)
57 | }
58 |
--------------------------------------------------------------------------------
/router/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | //设置dotserver日志目录
15 | app.SetLogPath(file.GetCurrentDirectory())
16 |
17 | //app.HttpServer.SetEnabledAutoHEAD(true)
18 |
19 | //设置路由
20 | InitRoute(app.HttpServer)
21 |
22 | //启动 监控服务
23 | //app.SetPProfConfig(true, 8081)
24 |
25 | // 开始服务
26 | port := 8080
27 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
28 | err := app.StartServer(port)
29 | fmt.Println("dotweb.StartServer error => ", err)
30 | }
31 |
32 | func Index(ctx dotweb.Context) error {
33 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
34 | flag := ctx.HttpServer().Router().MatchPath(ctx, "/d/:x/y")
35 | return ctx.WriteString("index - " + ctx.Request().Method + " - " + fmt.Sprint(flag))
36 | }
37 |
38 | func Any(ctx dotweb.Context) error {
39 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
40 | return ctx.WriteString("any - " + ctx.Request().Method)
41 | }
42 |
43 | func Group(ctx dotweb.Context) error {
44 | return ctx.WriteString("group - " + ctx.Request().Url())
45 | }
46 |
47 | func InitRoute(server *dotweb.HttpServer) {
48 | server.Router().GET("/", Index)
49 | server.Router().GET("/d/:x/y", Index)
50 | server.Router().GET("/any", Any)
51 | g := server.Group("/g")
52 | g.GET("/1", Group)
53 | g.GET("/2", Group)
54 | }
55 |
--------------------------------------------------------------------------------
/appcontext/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | //设置dotserver日志目录
15 | app.SetLogPath(file.GetCurrentDirectory())
16 |
17 | //设置路由
18 | InitRoute(app.HttpServer)
19 |
20 | //启动 监控服务
21 | //app.SetPProfConfig(true, 8081)
22 |
23 | //全局容器
24 | app.Items.Set("gstring", "gvalue")
25 | app.Items.Set("gint", 1)
26 |
27 | // 开始服务
28 | port := 8080
29 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
30 | err := app.StartServer(port)
31 | fmt.Println("dotweb.StartServer error => ", err)
32 | }
33 |
34 | type TestContext struct {
35 | UserName string
36 | Sex int
37 | }
38 |
39 | //you can curl http://127.0.0.1:8080/
40 | func Index(ctx dotweb.Context) error {
41 | gstring := ctx.Items().GetString("gstring")
42 | gint := ctx.Items().GetInt("gint")
43 | ctx.Items().Set("index", "index-v")
44 | ctx.Items().Set("user", "user-v")
45 | return ctx.WriteString("index -> " + gstring + ";" + strconv.Itoa(gint))
46 | }
47 |
48 | //you can curl http://127.0.0.1:8080/2
49 | func Index2(ctx dotweb.Context) error {
50 | gindex := ctx.Items().GetString("index")
51 | ctx.Items().Remove("index")
52 | user, _ := ctx.Items().Once("user")
53 | return ctx.WriteString("index -> " + gindex + ";" + fmt.Sprint(user))
54 | }
55 |
56 | func InitRoute(server *dotweb.HttpServer) {
57 | server.Router().GET("/", Index)
58 | server.Router().GET("/2", Index2)
59 | }
60 |
--------------------------------------------------------------------------------
/static/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | app.SetDevelopmentMode()
15 | //设置dotserver日志目录
16 | app.SetLogPath(file.GetCurrentDirectory())
17 |
18 | app.HttpServer.SetEnabledListDir(true)
19 | app.HttpServer.SetEnabledStaticFileMiddleware(true)
20 | //app.UseRequestLog()
21 | //设置路由
22 | InitRoute(app.HttpServer)
23 |
24 | //启动 监控服务
25 | //app.SetPProfConfig(true, 8081)
26 |
27 | app.SetNotFoundHandle(func(ctx dotweb.Context) {
28 | ctx.WriteStringC(200, "i'm here!")
29 | })
30 |
31 | // 开始服务
32 | port := 8080
33 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
34 | err := app.StartServer(port)
35 | fmt.Println("dotweb.StartServer error => ", err)
36 | }
37 |
38 | func InitRoute(server *dotweb.HttpServer) {
39 | /*g := server.Group("/files").Use(gzip.Middleware(gzip.NewConfig().UseDefault()))
40 | g.Use(&dotweb.RequestLogMiddleware{})
41 | g.ServerFile("/*", "D:/gotmp")
42 | server.ServerFile("/file2/*", "D:/my/vue-router")
43 | server.ServerFile("/file3/*", "D:/my/ng-web")
44 | server.GET("/test", func(ctx dotweb.Context) error {
45 | return ctx.WriteString("test gzip")
46 | }).Use(gzip.Middleware(gzip.NewConfig().UseDefault()))
47 |
48 |
49 | server.GET("/test2/:name", func(ctx dotweb.Context) error {
50 | return ctx.WriteString("test 2")
51 | })*/
52 | //server.ServerFile("/dst/*", "d:/gotmp")
53 | server.RegisterServerFile(dotweb.RouteMethod_GET, "/dst/*", "d:/gotmp", []string{".yaml", ".log"})
54 | }
55 |
--------------------------------------------------------------------------------
/file/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "strconv"
8 | )
9 |
10 | const FileRoot = "D:/gotmp/"
11 |
12 | func main() {
13 | //初始化DotServer
14 | app := dotweb.New()
15 |
16 | //设置dotserver日志目录
17 | app.SetLogPath(file.GetCurrentDirectory())
18 |
19 | app.HttpServer.SetEnabledListDir(true)
20 |
21 | //设置gzip开关
22 | //app.HttpServer.SetEnabledGzip(true)
23 |
24 | //设置路由
25 | InitRoute(app.HttpServer)
26 |
27 | //启动 监控服务
28 | //app.SetPProfConfig(true, 8081)
29 |
30 | // 开始服务
31 | port := 8080
32 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
33 | err := app.StartServer(port)
34 | fmt.Println("dotweb.StartServer error => ", err)
35 | }
36 |
37 | type UserInfo struct {
38 | UserName string
39 | Sex int
40 | }
41 |
42 | func FileWithDir(ctx dotweb.Context) error {
43 | ctx.Response().SetContentType(dotweb.MIMETextHTMLCharsetUTF8)
44 | return ctx.File(FileRoot)
45 | }
46 |
47 | func File(ctx dotweb.Context) error {
48 | return ctx.File(FileRoot+"dotweb.json.conf")
49 | }
50 |
51 | func Attachment(ctx dotweb.Context) error {
52 | return ctx.Attachment(FileRoot+"dotweb.json.conf", "json.conf")
53 | }
54 |
55 | func Inline(ctx dotweb.Context) error {
56 | return ctx.Inline(FileRoot+"dotweb.json.conf", "json.conf")
57 | }
58 |
59 | func InitRoute(server *dotweb.HttpServer) {
60 | server.Router().GET("/file", File)
61 | server.Router().GET("/dir", FileWithDir)
62 | server.Router().GET("/attachment", Attachment)
63 | server.Router().GET("/inline", Inline)
64 | server.Router().ServerFile("/static/*filepath", "D:/gotmp")
65 | }
66 |
--------------------------------------------------------------------------------
/bind/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | //设置dotserver日志目录
15 | app.SetLogPath(file.GetCurrentDirectory())
16 |
17 | //这里仅为示例,默认情况下,开启的模式就是development模式
18 | app.SetDevelopmentMode()
19 |
20 | //设置gzip开关
21 | //app.HttpServer.SetEnabledGzip(true)
22 |
23 | //设置路由
24 | InitRoute(app.HttpServer)
25 |
26 | //启动 监控服务
27 | //app.SetPProfConfig(true, 8081)
28 |
29 | // 开始服务
30 | port := 8080
31 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
32 | err := app.StartServer(port)
33 | fmt.Println("dotweb.StartServer error => ", err)
34 | }
35 |
36 | func TestBind(ctx dotweb.Context) error {
37 | type UserInfo struct {
38 | UserName string
39 | Sex int
40 | }
41 | user := new(UserInfo)
42 | errstr := "no error"
43 | if err := ctx.Bind(user); err != nil {
44 | errstr = err.Error()
45 | } else {
46 |
47 | }
48 |
49 | err := ctx.WriteString("TestBind [" + errstr + "] " + fmt.Sprint(user))
50 | return err
51 | }
52 |
53 | func GetBind(ctx dotweb.Context) error {
54 | type UserInfo struct {
55 | UserName string `form:"user"`
56 | Sex int `form:"sex"`
57 | }
58 | user := new(UserInfo)
59 | errstr := "no error"
60 | if err := ctx.Bind(user); err != nil {
61 | errstr = err.Error()
62 | } else {
63 |
64 | }
65 |
66 | err := ctx.WriteString("GetBind [" + errstr + "] " + fmt.Sprint(user))
67 | return err
68 | }
69 |
70 | func InitRoute(server *dotweb.HttpServer) {
71 | server.Router().POST("/", TestBind)
72 | server.Router().GET("/getbind", GetBind)
73 | }
74 |
--------------------------------------------------------------------------------
/cache/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/cache"
7 | "github.com/devfeel/dotweb/framework/file"
8 | "strconv"
9 | )
10 |
11 | func main() {
12 | //初始化DotServer
13 | app := dotweb.New()
14 |
15 | //设置dotserver日志目录
16 | app.SetLogPath(file.GetCurrentDirectory())
17 |
18 | //设置gzip开关
19 | //app.HttpServer.SetEnabledGzip(true)
20 |
21 | //设置路由
22 | InitRoute(app.HttpServer)
23 |
24 | //启动 监控服务
25 | //app.SetPProfConfig(true, 8081)
26 |
27 | //app.SetCache(cache.NewRuntimeCache())
28 | app.SetCache(cache.NewRedisCache("127.0.0.1:6379"))
29 |
30 | err := app.Cache().Set("g", "gv", 20)
31 | if err != nil {
32 | fmt.Println("Cache Set ", err)
33 | }
34 |
35 | // 开始服务
36 | port := 8080
37 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
38 | err = app.StartServer(port)
39 | fmt.Println("dotweb.StartServer error => ", err)
40 | }
41 |
42 | type UserInfo struct {
43 | UserName string
44 | Sex int
45 | }
46 |
47 | func One(ctx dotweb.Context) error {
48 | g, err := ctx.Cache().GetString("g")
49 | if err != nil {
50 | g = err.Error()
51 | }
52 | _, err = ctx.Cache().Incr("count")
53 | return ctx.WriteString("One [" + g + "] " + fmt.Sprint(err))
54 | }
55 |
56 | func Two(ctx dotweb.Context) error {
57 | g, err := ctx.Cache().GetString("g")
58 | if err != nil {
59 | g = err.Error()
60 | }
61 | _, err = ctx.Cache().Incr("count")
62 | c, _ := ctx.Cache().GetString("count")
63 | err = ctx.WriteString("Two [" + g + "] [" + c + "] " + fmt.Sprint(err))
64 | return err
65 | }
66 |
67 | func InitRoute(server *dotweb.HttpServer) {
68 | server.Router().GET("/1", One)
69 | server.Router().GET("/2", Two)
70 | }
71 |
--------------------------------------------------------------------------------
/render/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "strconv"
8 | )
9 |
10 | func main() {
11 | //初始化DotServer
12 | app := dotweb.New()
13 |
14 | //设置dotserver日志目录
15 | app.SetLogPath(file.GetCurrentDirectory())
16 |
17 | //设置gzip开关
18 | //app.HttpServer.SetEnabledGzip(true)
19 |
20 | //设置路由
21 | InitRoute(app.HttpServer)
22 |
23 | //set default template path, support multi path
24 | //模板查找顺序从最后一个插入的元素开始往前找
25 | //默认添加base、base/templates、base/views
26 | //app.HttpServer.Renderer().SetTemplatePath("d:/gotmp")
27 |
28 | //启动 监控服务
29 | //app.SetPProfConfig(true, 8081)
30 |
31 | // 开始服务
32 | port := 8080
33 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
34 | err := app.StartServer(port)
35 | fmt.Println("dotweb.StartServer error => ", err)
36 | }
37 |
38 | type UserInfo struct {
39 | UserName string
40 | Sex bool
41 | }
42 |
43 | type BookInfo struct {
44 | Name string
45 | Size int64
46 | }
47 |
48 | func NotExistView(ctx dotweb.Context) error {
49 | err := ctx.View("1.html")
50 | return err
51 | }
52 |
53 | func TestView(ctx dotweb.Context) error {
54 | ctx.ViewData().Set("data", "图书信息")
55 | ctx.ViewData().Set("user", &UserInfo{UserName: "user1", Sex: true})
56 | m := make([]*BookInfo, 5)
57 | m[0] = &BookInfo{Name: "book0", Size: 1}
58 | m[1] = &BookInfo{Name: "book1", Size: 10}
59 | m[2] = &BookInfo{Name: "book2", Size: 100}
60 | m[3] = &BookInfo{Name: "book3", Size: 1000}
61 | m[4] = &BookInfo{Name: "book4", Size: 10000}
62 | ctx.ViewData().Set("Books", m)
63 |
64 | err := ctx.View("d:/gotmp/testview.html")
65 | return err
66 | }
67 |
68 | func InitRoute(server *dotweb.HttpServer) {
69 | server.Router().GET("/", TestView)
70 | server.Router().GET("/noview", NotExistView)
71 | }
72 |
--------------------------------------------------------------------------------
/uploadfile/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "strconv"
7 | )
8 |
9 | func main() {
10 | //初始化DotServer
11 | app := dotweb.New()
12 |
13 | //启用开发模式
14 | app.SetDevelopmentMode()
15 | //启用访问日志
16 | app.SetEnabledLog(true)
17 | app.UseRequestLog()
18 |
19 | //设置路由
20 | InitRoute(app.HttpServer)
21 |
22 | // 开始服务
23 | port := 8080
24 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
25 | err := app.StartServer(port)
26 | fmt.Println("dotweb.StartServer error => ", err)
27 | }
28 |
29 | func InitRoute(server *dotweb.HttpServer) {
30 | server.Router().POST("/file", FileUpload)
31 | server.Router().POST("/files", FileUploads)
32 | }
33 |
34 | func FileUpload(ctx dotweb.Context) error {
35 | upload, err := ctx.Request().FormFile("file")
36 | if err != nil {
37 | return ctx.WriteString("FormFile error " + err.Error())
38 | } else {
39 | _, err = upload.SaveFile("D:/gotmp/uploads/" + upload.FileName())
40 | fmt.Println(string(upload.ReadBytes()))
41 | if err != nil {
42 | return ctx.WriteString("SaveFile error => " + err.Error())
43 | } else {
44 | return ctx.WriteString("SaveFile success || " + upload.FileName() + " || " + upload.RandomFileName() + " || " + upload.GetFileExt() + " || " + fmt.Sprint(upload.Size()))
45 | }
46 | }
47 |
48 | }
49 |
50 | func FileUploads(ctx dotweb.Context) error {
51 | retString := ""
52 | fileMap, err:=ctx.Request().FormFiles()
53 | if err!= nil{
54 | return ctx.WriteString("FormFiles error " + err.Error())
55 | }else {
56 | for _, upload:=range fileMap{
57 | _, err = upload.SaveFile("d:\\" + upload.FileName())
58 | if err != nil {
59 | retString += "SaveFile " + upload.FileName() + " error => " + err.Error() + "\r\n"
60 | } else {
61 | retString += "SaveFile success || " + upload.FileName() + " || " + upload.GetFileExt() + " || " + fmt.Sprint(upload.Size())
62 | retString += "\r\n"
63 | }
64 | }
65 | }
66 |
67 | return ctx.WriteString(retString)
68 | }
69 |
--------------------------------------------------------------------------------
/config/dotweb.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/render_pango2/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "strconv"
6 | "github.com/devfeel/dotweb"
7 | "io"
8 | "github.com/flosch/pongo2"
9 | )
10 | type UserInfo struct {
11 | UserName string
12 | Sex bool
13 | }
14 |
15 | type BookInfo struct {
16 | Name string
17 | Size int64
18 | }
19 |
20 |
21 | func main() {
22 | //初始化DotServer
23 | app := dotweb.New()
24 |
25 | app.SetDevelopmentMode()
26 |
27 | //设置路由
28 | InitRoute(app.HttpServer)
29 |
30 | app.HttpServer.SetRenderer(new(pango2Render))
31 |
32 | // 开始服务
33 | port := 8080
34 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
35 | err := app.StartServer(port)
36 | fmt.Println("dotweb.StartServer error => ", err)
37 | }
38 |
39 |
40 | func NotExistView(ctx dotweb.Context) error {
41 | err := ctx.View("1.html")
42 | return err
43 | }
44 |
45 | func TestView(ctx dotweb.Context) error {
46 | ctx.ViewData().Set("data", "图书信息")
47 | ctx.ViewData().Set("user", &UserInfo{UserName: "user1", Sex: true})
48 | m := make([]*BookInfo, 5)
49 | m[0] = &BookInfo{Name: "book0", Size: 1}
50 | m[1] = &BookInfo{Name: "book1", Size: 10}
51 | m[2] = &BookInfo{Name: "book2", Size: 100}
52 | m[3] = &BookInfo{Name: "book3", Size: 1000}
53 | m[4] = &BookInfo{Name: "book4", Size: 10000}
54 | ctx.ViewData().Set("Books", m)
55 |
56 | err := ctx.View("d:/gotmp/pango2_testview.html")
57 | return err
58 | }
59 |
60 | func InitRoute(server *dotweb.HttpServer) {
61 | server.Router().GET("/", TestView)
62 | server.Router().GET("/noview", NotExistView)
63 | }
64 |
65 |
66 | type pango2Render struct{
67 | templatePath string
68 | }
69 |
70 | func (r *pango2Render) SetTemplatePath(path string){
71 | r.templatePath = path
72 | }
73 |
74 | func (r *pango2Render) Render(w io.Writer, data interface{}, ctx dotweb.Context, tpl ...string) error{
75 | tplExample, err := pongo2.FromFile(tpl[0])
76 | var contentMap pongo2.Context
77 | itemMap, isOk:=data.(map[string]interface{})
78 | if isOk{
79 | contentMap = itemMap
80 | }
81 | err = tplExample.ExecuteWriter(contentMap, w)
82 | return err
83 | }
--------------------------------------------------------------------------------
/performance/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "strconv"
7 | "time"
8 | "github.com/devfeel/cache"
9 | "net"
10 | )
11 | const redisServer = "redis://192.168.8.175:6379/0"
12 | var redisCache = cache.GetRedisCachePoolConf(redisServer, 100, 1000)
13 | var IpAddr string
14 | func main() {
15 | //初始化DotServer
16 | app := dotweb.New()
17 | //设置路由
18 | InitRoute(app.HttpServer)
19 |
20 | //app.SetPProfConfig(true, 8091)
21 |
22 | ips, _ := net.InterfaceAddrs()
23 | for _, addr := range ips {
24 | if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
25 | if nil != ipnet.IP.To4() {
26 | IpAddr = ipnet.IP.String()
27 | break
28 | }
29 | }
30 | }
31 |
32 |
33 | redisCache.Set("dotweb-example-1", 1, 0)
34 |
35 | // 开始服务
36 | port := 8080
37 | fmt.Println("[" + IpAddr+"] dotweb.StartServer => " + strconv.Itoa(port))
38 | err := app.StartServer(port)
39 | fmt.Println("dotweb.StartServer error => ", err)
40 | }
41 |
42 | func Test(ctx dotweb.Context) error {
43 | ctx.WriteString("hello dotweb!")
44 | return nil
45 | }
46 |
47 | func TestRedis(ctx dotweb.Context) error{
48 | ctx.Response().SetHeader("redis-server", IpAddr)
49 | begin := time.Now()
50 | data, err := redisCache.Get("dotweb-example-1")
51 | if err != nil{
52 | fmt.Println(time.Now(), err)
53 | }
54 | timespan := time.Now().Sub(begin).Nanoseconds()
55 | if timespan >= 500000000{
56 | fmt.Println(time.Now(), "timespan big", timespan)
57 | }
58 | return ctx.WriteString(data, err, timespan)
59 | }
60 |
61 | func TestWait30(ctx dotweb.Context) error {
62 | time.Sleep(30 * time.Millisecond)
63 | ctx.WriteString("hello dotweb!")
64 | return nil
65 | }
66 |
67 | func TestWait100(ctx dotweb.Context) error {
68 | time.Sleep(100 * time.Millisecond)
69 | ctx.WriteString("hello dotweb!")
70 | return nil
71 | }
72 |
73 | func TestWait1000(ctx dotweb.Context) error {
74 | time.Sleep(1000 * time.Millisecond)
75 | ctx.WriteString("hello dotweb!")
76 | return nil
77 | }
78 |
79 | func InitRoute(server *dotweb.HttpServer) {
80 | server.Router().GET("/", Test)
81 | server.Router().GET("/redis", TestRedis)
82 | server.Router().GET("/wait30", TestWait30)
83 | server.Router().GET("/wait100", TestWait100)
84 | server.Router().GET("/wait1000", TestWait1000)
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/session/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/gob"
5 | "fmt"
6 | "github.com/devfeel/dotweb"
7 | "github.com/devfeel/dotweb/framework/file"
8 | "github.com/devfeel/dotweb/session"
9 | "strconv"
10 | )
11 |
12 | func main() {
13 | //初始化DotServer
14 | app := dotweb.New()
15 |
16 | app.SetDevelopmentMode()
17 |
18 | //设置dotserver日志目录
19 | app.SetLogPath(file.GetCurrentDirectory())
20 |
21 | //设置Session开关
22 | app.HttpServer.SetEnabledSession(true)
23 |
24 | //设置Session配置
25 | //runtime mode
26 | sessionConf := session.NewDefaultRuntimeConfig()
27 | sessionConf.CookieName = "dotweb-example.SessionID"
28 | app.HttpServer.SetSessionConfig(sessionConf)
29 | //redis mode
30 | //sessionConf := session.NewDefaultRedisConfig("redis://47.75.211.166:6379/0")
31 | //sessionConf.BackupServerUrl = "redis://47.75.211.166:6379/0"
32 | //sessionConf.CookieName = "dotweb-example.SessionID"
33 | //sessionConf.MaxIdle = 20
34 | //sessionConf.MaxActive = 100
35 | //app.HttpServer.SetSessionConfig(sessionConf)
36 | //app.HttpServer.SetSessionConfig(session.NewRedisConfig("redis://:123456@192.168.8.175:7001/1", "dotweb-example:session:"))
37 |
38 | //设置路由
39 | InitRoute(app.HttpServer)
40 |
41 | // 开始服务
42 | port := 8080
43 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
44 | err := app.StartServer(port)
45 | fmt.Println("dotweb.StartServer error => ", err)
46 | }
47 |
48 | type UserInfo struct {
49 | UserName string
50 | NickName string
51 | }
52 |
53 | func init() {
54 | gob.Register(UserInfo{})
55 | }
56 |
57 | func TestSession(ctx dotweb.Context) error {
58 |
59 | user := UserInfo{UserName: "test", NickName: "testName"}
60 | var userRead UserInfo
61 |
62 | ctx.WriteString("welcome to dotweb - CreateSession - sessionid=> "+ctx.SessionID(), "\r\n")
63 | err := ctx.Session().Set("username", user)
64 | if err != nil {
65 | ctx.WriteString("session set error => ", err, "\r\n")
66 | }
67 | c := ctx.Session().Get("username")
68 | if c != nil {
69 | userRead = c.(UserInfo)
70 | } else {
71 | ctx.WriteString("session read failed, get nil", "\r\n")
72 | }
73 |
74 | return ctx.WriteString("userinfo=>" + fmt.Sprintln(userRead))
75 | return err
76 | }
77 |
78 | func TestReadSession(ctx dotweb.Context) error {
79 |
80 | var userRead UserInfo
81 |
82 | ctx.WriteString("welcome to dotweb - ReadSession - sessionid=> "+ctx.SessionID(), "\r\n")
83 |
84 | c := ctx.Session().Get("username")
85 | if c != nil {
86 | userRead = c.(UserInfo)
87 | } else {
88 | ctx.WriteString("session read failed, get nil", "\r\n")
89 | }
90 |
91 | return ctx.WriteString("userinfo=>" + fmt.Sprintln(userRead))
92 | }
93 |
94 | func InitRoute(server *dotweb.HttpServer) {
95 | server.Router().GET("/", TestSession)
96 | server.Router().GET("/read", TestReadSession)
97 | }
98 |
--------------------------------------------------------------------------------
/middleware/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "net/http"
7 | "strconv"
8 | "time"
9 | )
10 |
11 | func main() {
12 | //初始化DotServer
13 | app := dotweb.New()
14 |
15 | //设置dotserver日志目录
16 | //如果不设置,默认不启用,且默认为当前目录
17 | app.SetEnabledLog(true)
18 |
19 | //开启development模式
20 | app.SetDevelopmentMode()
21 |
22 | //设置gzip开关
23 | //app.SetEnabledGzip(true)
24 |
25 | //设置路由
26 | InitRoute(app.HttpServer)
27 |
28 | app.UseRequestLog()
29 | app.Use(
30 | NewAccessFmtLog("app"),
31 | //NewSimpleAuth("admin"),
32 | )
33 |
34 |
35 | // 开始服务
36 | port := 8080
37 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
38 | err := app.StartServer(port)
39 | fmt.Println("dotweb.StartServer error => ", err)
40 | }
41 |
42 | func Index(ctx dotweb.Context) error {
43 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
44 | fmt.Println(time.Now(), "Index Handler - ", ctx.Request().Url())
45 | return ctx.WriteString("index => ", fmt.Sprint(ctx.RouterNode().Middlewares()))
46 | }
47 |
48 | func Delete(ctx dotweb.Context) error {
49 | return ctx.WriteString("Delete => ", fmt.Sprint(ctx.RouterNode().Middlewares()))
50 | }
51 |
52 | func InitRoute(server *dotweb.HttpServer) {
53 | server.Router().GET("/", Index)
54 | server.DELETE("/del", Delete).Use(NewAccessFmtLog("Router-del"))
55 | server.Router().GET("/use", Index).Use(NewAccessFmtLog("Router-use"))
56 |
57 | g := server.Group("/group").Use(NewAccessFmtLog("group")).Use(NewSimpleAuth("admin"))
58 | g.GET("/", Index)
59 | g.GET("/use", Index).Use(NewAccessFmtLog("group-use"))
60 | }
61 |
62 | type AccessFmtLog struct {
63 | dotweb.BaseMiddlware
64 | Index string
65 | }
66 |
67 | func (m *AccessFmtLog) Handle(ctx dotweb.Context) error {
68 | fmt.Println(time.Now(), "[AccessFmtLog ", m.Index, "] begin request -> ", ctx.Request().RequestURI)
69 | err := m.Next(ctx)
70 | fmt.Println(time.Now(), "[AccessFmtLog ", m.Index, "] finish request ", err, " -> ", ctx.Request().RequestURI)
71 | return err
72 | }
73 |
74 | func NewAccessFmtLog(index string) *AccessFmtLog {
75 | return &AccessFmtLog{Index: index}
76 | }
77 |
78 | type SimpleAuth struct {
79 | dotweb.BaseMiddlware
80 | exactToken string
81 | }
82 |
83 | func (m *SimpleAuth) Handle(ctx dotweb.Context) error {
84 | fmt.Println(time.Now(), "[SimpleAuth] begin request -> ", ctx.Request().RequestURI)
85 | var err error
86 | if ctx.QueryString("token") != m.exactToken {
87 | ctx.Write(http.StatusUnauthorized, []byte("sorry, Unauthorized"))
88 | } else {
89 | err = m.Next(ctx)
90 | }
91 | fmt.Println(time.Now(), "[SimpleAuth] finish request ", err, " -> ", ctx.Request().RequestURI)
92 | return err
93 | }
94 |
95 | func NewSimpleAuth(exactToken string) *SimpleAuth {
96 | return &SimpleAuth{exactToken: exactToken}
97 | }
98 |
--------------------------------------------------------------------------------
/httpmodule/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/framework/file"
7 | "github.com/devfeel/dotweb/session"
8 | "strconv"
9 | )
10 |
11 | func main() {
12 | //初始化DotServer
13 | app := dotweb.New()
14 |
15 | //设置dotserver日志目录
16 | app.SetLogPath(file.GetCurrentDirectory())
17 |
18 | //设置gzip开关
19 | //app.HttpServer.SetEnabledGzip(true)
20 |
21 | app.SetDevelopmentMode()
22 |
23 | //设置Session开关
24 | app.HttpServer.SetEnabledSession(true)
25 |
26 | app.HttpServer.SetEnabledIgnoreFavicon(true)
27 |
28 | //设置Session配置
29 | //runtime mode
30 | app.HttpServer.SetSessionConfig(session.NewDefaultRuntimeConfig())
31 | //redis mode
32 | //app.SetSessionConfig(session.NewDefaultRedisConfig("192.168.8.175:6379", ""))
33 |
34 | //设置路由
35 | InitRoute(app.HttpServer)
36 |
37 | //设置HttpModule
38 | InitModule(app.HttpServer)
39 |
40 | //启动 监控服务
41 | //app.SetPProfConfig(true, 8081)
42 |
43 | //全局容器
44 | app.Items.Set("gstring", "gvalue")
45 | app.Items.Set("gint", 1)
46 |
47 | // 开始服务
48 | port := 8080
49 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
50 | err := app.StartServer(port)
51 | fmt.Println("dotweb.StartServer error => ", err)
52 | }
53 |
54 | func Index(ctx dotweb.Context) error {
55 | ctx.Items().Set("count", 2)
56 | ctx.WriteString(ctx.Request().Path() + ":Items.Count=> " + ctx.Items().GetString("count"))
57 | return ctx.WriteString("\r\n")
58 | }
59 |
60 | func WHtml(ctx dotweb.Context) error {
61 | ctx.WriteHtml("this is html response!")
62 | return nil
63 | }
64 |
65 | func InitRoute(server *dotweb.HttpServer) {
66 | server.GET("/", Index)
67 | server.GET("/m", Index)
68 | server.GET("/h", WHtml)
69 | }
70 |
71 | func InitModule(dotserver *dotweb.HttpServer) {
72 | dotserver.RegisterModule(&dotweb.HttpModule{
73 | Name: "test change route",
74 | OnBeginRequest: func(ctx dotweb.Context) {
75 | if ctx.IsEnd() {
76 | return
77 | }
78 | if ctx.Request().Path() == "/" && ctx.QueryString("change") == "1" {
79 | //change route
80 | ctx.WriteString("变更访问路由测试")
81 | ctx.WriteString("\r\n")
82 | ctx.Request().URL.Path = "/m"
83 | }
84 |
85 | if ctx.Request().Path() == "/" {
86 | ctx.Items().Set("count", 1)
87 | ctx.WriteString("OnBeginRequest:Items.Count => ", ctx.Items().GetString("count"))
88 | ctx.WriteString("\r\n")
89 | }
90 | if ctx.QueryString("skip") == "1" {
91 | ctx.End()
92 | }
93 | },
94 | OnEndRequest: func(ctx dotweb.Context) {
95 | if ctx.IsEnd() {
96 | return
97 | }
98 | if ctx.Request().Path() == "/" {
99 | if ctx.Items().Exists("count") {
100 | ctx.WriteString("OnEndRequest:Items.Count => ", ctx.Items().GetString("count"))
101 | } else {
102 | ctx.WriteString("OnEndRequest:Items.Len => ", ctx.Items().Len())
103 | }
104 | }
105 | },
106 | })
107 | }
108 |
--------------------------------------------------------------------------------
/logger/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/logger"
7 | "os"
8 | "strconv"
9 | "strings"
10 | "syscall"
11 | "time"
12 | )
13 |
14 | func main() {
15 | //初始化DotServer
16 | app := dotweb.New()
17 |
18 | //设置dotserver日志目录
19 | //如果不设置,默认启用,且默认为当前目录
20 | //app.SetLogger(NewYLog())
21 | app.SetEnabledLog(true)
22 | app.SetLogPath("d:/gotmp/xlog/xlog1/xlog2/")
23 |
24 | fmt.Println(logger.Logger())
25 |
26 | //开启development模式
27 | app.SetDevelopmentMode()
28 |
29 | //设置路由
30 | InitRoute(app.HttpServer)
31 |
32 | //启动 监控服务
33 | app.SetPProfConfig(true, 8081)
34 |
35 | // 开始服务
36 | port := 8080
37 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
38 | err := app.StartServer(port)
39 | fmt.Println("dotweb.StartServer error => ", err)
40 | }
41 |
42 | func Index(ctx dotweb.Context) error {
43 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
44 | logger.Logger().Debug("debug", "x")
45 | logger.Logger().Info("info", "x")
46 | logger.Logger().Warn("warn", "x")
47 | logger.Logger().Error("error", "x")
48 | return ctx.WriteStringC(201, "index => ", ctx.RouterParams())
49 | }
50 |
51 | func InitRoute(server *dotweb.HttpServer) {
52 | server.Router().GET("/", Index)
53 | }
54 |
55 | type chanLog struct {
56 | Content string
57 | LogTarget string
58 | }
59 |
60 | type yLog struct {
61 | logRootPath string
62 | logChan_Custom chan chanLog
63 | enabledLog bool
64 | }
65 |
66 | //create new yLog
67 | func NewYLog() *yLog {
68 | l := &yLog{logChan_Custom: make(chan chanLog, 10000)}
69 | go l.handleCustom()
70 | return l
71 | }
72 |
73 | const (
74 | defaultDateFormatForFileName = "2006_01_02"
75 | defaultDateLayout = "2006-01-02"
76 | defaultFullTimeLayout = "2006-01-02 15:04:05.999999"
77 | defaultTimeLayout = "2006-01-02 15:04:05"
78 | )
79 |
80 | func (l *yLog) Print(log string, logTarget string) {
81 | l.Log(log, logTarget, "debug")
82 | }
83 |
84 | func (l *yLog) Debug(log string, logTarget string) {
85 | l.Log(log, logTarget, "debug")
86 | }
87 |
88 | func (l *yLog) Info(log string, logTarget string) {
89 | l.Log(log, logTarget, "info")
90 | }
91 |
92 | func (l *yLog) Warn(log string, logTarget string) {
93 | l.Log(log, logTarget, "warn")
94 | }
95 |
96 | func (l *yLog) Error(log string, logTarget string) {
97 | l.Log(log, logTarget, "error")
98 | }
99 |
100 | func (l *yLog) Log(log string, logTarget string, logLevel string) {
101 | if l.enabledLog {
102 | chanLog := chanLog{
103 | LogTarget: "yLog_" + logTarget + "_" + logLevel,
104 | Content: log,
105 | }
106 | l.logChan_Custom <- chanLog
107 | }
108 | }
109 |
110 | //set log path
111 | func (l *yLog) SetLogPath(rootPath string) {
112 | //设置日志根目录
113 | l.logRootPath = rootPath
114 | if !strings.HasSuffix(l.logRootPath, "/") {
115 | l.logRootPath = l.logRootPath + "/"
116 | }
117 | }
118 |
119 | //set enabled log
120 | func (l *yLog) SetEnabledLog(enabledLog bool) {
121 | l.enabledLog = enabledLog
122 | }
123 |
124 | //处理日志内部函数
125 | func (l *yLog) handleCustom() {
126 | for {
127 | log := <-l.logChan_Custom
128 | l.writeLog(log, "custom")
129 | }
130 | }
131 |
132 | func (l *yLog) writeLog(chanLog chanLog, level string) {
133 | filePath := l.logRootPath + chanLog.LogTarget
134 | switch level {
135 | case "custom":
136 | filePath = filePath + "_" + time.Now().Format(defaultDateFormatForFileName) + ".log"
137 | break
138 | }
139 | log := time.Now().Format(defaultFullTimeLayout) + " " + chanLog.Content
140 | writeFile(filePath, log)
141 | }
142 |
143 | func writeFile(logFile string, log string) {
144 | var mode os.FileMode
145 | flag := syscall.O_RDWR | syscall.O_APPEND | syscall.O_CREAT
146 | mode = 0666
147 | logstr := log + "\r\n"
148 | file, err := os.OpenFile(logFile, flag, mode)
149 | defer file.Close()
150 | if err != nil {
151 | fmt.Println(logFile, err)
152 | return
153 | }
154 | //fmt.Print(logstr)
155 | file.WriteString(logstr)
156 | }
157 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "github.com/devfeel/dotweb"
6 | "github.com/devfeel/dotweb/session"
7 | "net/http"
8 | "strconv"
9 | "net/url"
10 | "strings"
11 | )
12 |
13 | func main() {
14 | //初始化DotServer
15 | app := dotweb.New()
16 |
17 | app.UseRequestLog()
18 | //设置gzip开关
19 | //app.HttpServer.SetEnabledGzip(true)
20 |
21 | //设置Session开关
22 | app.HttpServer.SetEnabledSession(true)
23 |
24 | //设置Session配置
25 | //runtime mode
26 | app.HttpServer.SetSessionConfig(session.NewDefaultRuntimeConfig())
27 | //redis mode
28 | //app.SetSessionConfig(session.NewDefaultRedisConfig("192.168.8.175:6379", ""))
29 |
30 | //设置路由
31 | InitRoute(app.HttpServer)
32 |
33 | //设置HttpModule
34 | //InitModule(app)
35 |
36 | //启动 监控服务
37 | //pprofport := 8081
38 | //app.SetPProfConfig(true, pprofport)
39 |
40 | app.SetNotFoundHandle(func(context dotweb.Context) {
41 | context.Response().SetHeader("dotweb-t", "tres")
42 | context.WriteJsonC(http.StatusNotFound, "Not Found Json")
43 | })
44 |
45 | //全局容器
46 | app.Items.Set("gstring", "gvalue")
47 | app.Items.Set("gint", 1)
48 |
49 | // 开始服务
50 | port := 8080
51 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
52 | err := app.StartServer(port)
53 | fmt.Println("dotweb.StartServer error => ", err)
54 | }
55 |
56 | func EchoUrl(ctx dotweb.Context) error{
57 | fmt.Println(ctx.Request().URL)
58 | fmt.Println(ctx.Request().Url())
59 | fmt.Println(fmt.Sprintf(fmt.Sprintf("%s", ctx.Request().Url())))
60 |
61 | fmt.Println(url.QueryEscape(ctx.Request().QueryString("pageurl")))
62 |
63 | return ctx.WriteString(ctx.Request().RequestURI)
64 | }
65 |
66 | func Index(ctx dotweb.Context) error {
67 | //ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
68 | fmt.Println("Index")
69 | if strings.Index(ctx.Request().Host, ":") >0{
70 | ctx.WriteString(strings.Split(ctx.Request().Host, ":")[0])
71 | }else{
72 | ctx.WriteString(ctx.Request().Host)
73 | }
74 |
75 | return nil
76 | }
77 |
78 | func IndexReg(ctx dotweb.Context) error {
79 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
80 | ctx.WriteString("welcome to dotweb")
81 | return nil
82 | }
83 |
84 | func KeyPost(ctx dotweb.Context) error {
85 | username1 := ctx.Request().PostString("username")
86 | username2 := ctx.FormValue("username")
87 | username3 := ctx.PostFormValue("username")
88 | ctx.WriteString("username:" + username1 + " - " + username2 + " - " + username3)
89 | return nil
90 | }
91 |
92 | func JsonPost(ctx dotweb.Context) error {
93 | ctx.WriteString("body:" + string(ctx.Request().PostBody()))
94 | return nil
95 | }
96 |
97 | func DefaultError(ctx dotweb.Context) error {
98 | panic("my panic error!")
99 | return nil
100 | }
101 |
102 | func Redirect(ctx dotweb.Context) error {
103 | ctx.Redirect(http.StatusOK, "http://www.baidu.com")
104 | return nil
105 | }
106 |
107 | func InitRoute(server *dotweb.HttpServer) {
108 | server.Router().GET("/Page/PageView", EchoUrl)
109 | server.Router().GET("/", Index)
110 | server.Router().POST("/keypost", KeyPost)
111 | server.Router().POST("/jsonpost", JsonPost)
112 | server.Router().GET("/error", DefaultError)
113 | server.Router().GET("/redirect", Redirect)
114 | server.Router().RegisterRoute(dotweb.RouteMethod_GET, "/index", IndexReg)
115 | }
116 |
117 | func InitModule(dotserver *dotweb.DotWeb) {
118 | dotserver.HttpServer.RegisterModule(&dotweb.HttpModule{
119 | Name:"test change route",
120 | OnBeginRequest: func(ctx dotweb.Context) {
121 | fmt.Println("BeginRequest1:", ctx)
122 | },
123 | OnEndRequest: func(ctx dotweb.Context) {
124 | fmt.Println("EndRequest1:", ctx)
125 | },
126 | })
127 |
128 | dotserver.HttpServer.RegisterModule(&dotweb.HttpModule{
129 | OnBeginRequest: func(ctx dotweb.Context) {
130 | fmt.Println("BeginRequest2:", ctx)
131 | },
132 | })
133 | dotserver.HttpServer.RegisterModule(&dotweb.HttpModule{
134 | OnEndRequest: func(ctx dotweb.Context) {
135 | fmt.Println("EndRequest3:", ctx)
136 | },
137 | })
138 | }
139 |
--------------------------------------------------------------------------------
/config/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "errors"
5 | "fmt"
6 | "github.com/devfeel/dotweb"
7 | "github.com/devfeel/dotweb/config"
8 | "github.com/devfeel/dotweb/framework/json"
9 | "net/http"
10 | "time"
11 | )
12 |
13 | func main() {
14 | //初始化DotServer
15 | app := dotweb.New()
16 |
17 | //注册HttpHandler
18 | RegisterHandler(app.HttpServer)
19 |
20 | //appConfig, err := config.InitConfig("d:/gotmp/dotweb.conf")
21 | //json config
22 | appConfig, err := config.InitConfig("d:/gotmp/dotweb.json.conf", "json")
23 | if err != nil {
24 | fmt.Println("dotweb.InitConfig error => " + fmt.Sprint(err))
25 | return
26 | }
27 | fmt.Println(jsonutil.GetJsonString(appConfig))
28 | RegisterMiddlewares(app)
29 |
30 | err = app.SetConfig(appConfig)
31 | if err != nil {
32 | fmt.Println("dotweb.SetConfig error => " + fmt.Sprint(err))
33 | return
34 | }
35 |
36 | fmt.Println("dotweb.StartServer => " + fmt.Sprint(appConfig))
37 | err = app.StartServer(appConfig.Server.Port)
38 | fmt.Println("dotweb.StartServer error => ", err)
39 | }
40 |
41 | func Index(ctx dotweb.Context) error {
42 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
43 | return ctx.WriteString("index => ", fmt.Sprint(ctx.RouterNode().Middlewares()))
44 | }
45 |
46 | func GetAppSet(ctx dotweb.Context) error {
47 | key := ctx.QueryString("key")
48 | return ctx.WriteString(ctx.Request().Url(), " => key = ", key, "set1", ctx.ConfigSet().GetString("set1"))
49 | }
50 |
51 | func DefaultPanic(ctx dotweb.Context) error {
52 | panic("my panic error!")
53 | return nil
54 | }
55 |
56 | func DefaultError(ctx dotweb.Context) error {
57 | err := errors.New("my return error")
58 | return err
59 | }
60 |
61 | func Redirect(ctx dotweb.Context) error {
62 | return ctx.Redirect(200, "http://www.baidu.com")
63 | }
64 |
65 | func Login(ctx dotweb.Context) error {
66 | return ctx.WriteString("login => ", fmt.Sprint(ctx.RouterNode().Middlewares()))
67 | }
68 |
69 | func Logout(ctx dotweb.Context) error {
70 | return ctx.WriteString("logout => ", fmt.Sprint(ctx.RouterNode().Middlewares()))
71 | }
72 |
73 | func RegisterHandler(server *dotweb.HttpServer) {
74 | server.Router().RegisterHandler("Index", Index)
75 | server.Router().RegisterHandler("Error", DefaultError)
76 | server.Router().RegisterHandler("Panic", DefaultPanic)
77 | server.Router().RegisterHandler("Redirect", Redirect)
78 | server.Router().RegisterHandler("Login", Login)
79 | server.Router().RegisterHandler("Logout", Logout)
80 | server.Router().RegisterHandler("appset", GetAppSet)
81 | }
82 |
83 | func RegisterMiddlewares(app *dotweb.DotWeb) {
84 | //集中注册middleware
85 | app.RegisterMiddlewareFunc("applog", NewAppAccessFmtLog)
86 | app.RegisterMiddlewareFunc("grouplog", NewGroupAccessFmtLog)
87 | app.RegisterMiddlewareFunc("urllog", NewUrlAccessFmtLog)
88 | app.RegisterMiddlewareFunc("simpleauth", NewSimpleAuth)
89 | }
90 |
91 | type AccessFmtLog struct {
92 | dotweb.BaseMiddlware
93 | Index string
94 | }
95 |
96 | func (m *AccessFmtLog) Handle(ctx dotweb.Context) error {
97 | fmt.Println(time.Now(), "[AccessFmtLog ", m.Index, "] begin request -> ", ctx.Request().RequestURI)
98 | err := m.Next(ctx)
99 | fmt.Println(time.Now(), "[AccessFmtLog ", m.Index, "] finish request ", err, " -> ", ctx.Request().RequestURI)
100 | return err
101 | }
102 |
103 | func NewAppAccessFmtLog() dotweb.Middleware {
104 | return &AccessFmtLog{Index: "app"}
105 | }
106 |
107 | func NewGroupAccessFmtLog() dotweb.Middleware {
108 | return &AccessFmtLog{Index: "group"}
109 | }
110 |
111 | func NewUrlAccessFmtLog() dotweb.Middleware {
112 | return &AccessFmtLog{Index: "url"}
113 | }
114 |
115 | type SimpleAuth struct {
116 | dotweb.BaseMiddlware
117 | exactToken string
118 | }
119 |
120 | func (m *SimpleAuth) Handle(ctx dotweb.Context) error {
121 | fmt.Println(time.Now(), "[SimpleAuth] begin request -> ", ctx.Request().RequestURI)
122 | var err error
123 | if ctx.QueryString("token") != m.exactToken {
124 | ctx.Write(http.StatusUnauthorized, []byte("sorry, Unauthorized"))
125 | } else {
126 | err = m.Next(ctx)
127 | }
128 | fmt.Println(time.Now(), "[SimpleAuth] finish request ", err, " -> ", ctx.Request().RequestURI)
129 | return err
130 | }
131 |
132 | func NewSimpleAuth() dotweb.Middleware {
133 | return &SimpleAuth{exactToken: "admin"}
134 | }
135 |
--------------------------------------------------------------------------------
/config/dotweb.json.conf:
--------------------------------------------------------------------------------
1 | {
2 | "App": {
3 | "LogPath": "d:/gotmp/",
4 | "EnabledLog": true,
5 | "RunMode": "development",
6 | "PProfPort": 0,
7 | "EnabledPProf": false
8 | },
9 | "AppSets": [
10 | {
11 | "Key": "set1",
12 | "Value": "1"
13 | },
14 | {
15 | "Key": "set2",
16 | "Value": "2"
17 | },
18 | {
19 | "Key": "set3",
20 | "Value": "3"
21 | },
22 | {
23 | "Key": "set4",
24 | "Value": "4"
25 | }
26 | ],
27 | "Offline": {
28 | "Offline": false,
29 | "OfflineText": "server is offline!",
30 | "OfflineUrl": ""
31 | },
32 | "Server": {
33 | "EnabledListDir": false,
34 | "EnabledGzip": false,
35 | "EnabledAutoHEAD": true,
36 | "EnabledAutoCORS": false,
37 | "Port": 8080
38 | },
39 | "Session": {
40 | "EnabledSession": true,
41 | "SessionMode": "runtime",
42 | "Timeout": 20,
43 | "ServerIP": "",
44 | "UserName": "",
45 | "Password": ""
46 | },
47 | "Routers": [
48 | {
49 | "Method": "GET",
50 | "Path": "/index",
51 | "HandlerName": "Index",
52 | "Middlewares": [
53 | {
54 | "Name": "urllog",
55 | "IsUse": true
56 | }
57 | ],
58 | "IsUse": true
59 | },
60 | {
61 | "Method": "GET",
62 | "Path": "/index2",
63 | "HandlerName": "Index",
64 | "Middlewares": [
65 | {
66 | "Name": "urllog",
67 | "IsUse": true
68 | }
69 | ],
70 | "IsUse": true
71 | },
72 | {
73 | "Method": "GET",
74 | "Path": "/index3",
75 | "HandlerName": "Index",
76 | "Middlewares": [
77 | {
78 | "Name": "urllog",
79 | "IsUse": true
80 | }
81 | ],
82 | "IsUse": true
83 | },
84 | {
85 | "Method": "GET",
86 | "Path": "/redirect",
87 | "HandlerName": "Redirect",
88 | "Middlewares": null,
89 | "IsUse": true
90 | },
91 | {
92 | "Method": "GET",
93 | "Path": "/error",
94 | "HandlerName": "Error",
95 | "Middlewares": null,
96 | "IsUse": true
97 | },
98 | {
99 | "Method": "GET",
100 | "Path": "/panic",
101 | "HandlerName": "Panic",
102 | "Middlewares": null,
103 | "IsUse": true
104 | },
105 | {
106 | "Method": "GET",
107 | "Path": "/appset",
108 | "HandlerName": "appset",
109 | "Middlewares": null,
110 | "IsUse": true
111 | }
112 | ],
113 | "Groups": [
114 | {
115 | "Path": "/admin",
116 | "Routers": [
117 | {
118 | "Method": "GET",
119 | "Path": "/login",
120 | "HandlerName": "Login",
121 | "Middlewares": [
122 | {
123 | "Name": "urllog",
124 | "IsUse": true
125 | }
126 | ],
127 | "IsUse": true
128 | },
129 | {
130 | "Method": "GET",
131 | "Path": "/login3",
132 | "HandlerName": "Login",
133 | "Middlewares": null,
134 | "IsUse": true
135 | },
136 | {
137 | "Method": "GET",
138 | "Path": "/logout",
139 | "HandlerName": "Logout",
140 | "Middlewares": null,
141 | "IsUse": true
142 | },
143 | {
144 | "Method": "GET",
145 | "Path": "/login2",
146 | "HandlerName": "Login",
147 | "Middlewares": null,
148 | "IsUse": true
149 | }
150 | ],
151 | "Middlewares": [
152 | {
153 | "Name": "grouplog",
154 | "IsUse": true
155 | },
156 | {
157 | "Name": "simpleauth",
158 | "IsUse": true
159 | }
160 | ],
161 | "IsUse": true
162 | }
163 | ],
164 | "Middlewares": [
165 | {
166 | "Name": "applog",
167 | "IsUse": true
168 | }
169 | ],
170 | "AppSetConfig": {}
171 | }
--------------------------------------------------------------------------------