From 2f4505d856a22ca7ac9dc7becedd12ff94eed565 Mon Sep 17 00:00:00 2001 From: kim Date: Fri, 31 Jul 2020 17:09:47 +0800 Subject: [PATCH] format --- tools/goctl/api/demo/config/config.go | 7 ---- tools/goctl/api/demo/demo.go | 25 -------------- tools/goctl/api/demo/etc/user.json | 8 ----- .../goctl/api/demo/handler/getuserhandler.go | 33 ------------------- tools/goctl/api/demo/handler/handlers.go | 17 ---------- tools/goctl/api/demo/svc/servicecontext.go | 4 --- 6 files changed, 94 deletions(-) delete mode 100644 tools/goctl/api/demo/config/config.go delete mode 100644 tools/goctl/api/demo/demo.go delete mode 100644 tools/goctl/api/demo/etc/user.json delete mode 100644 tools/goctl/api/demo/handler/getuserhandler.go delete mode 100644 tools/goctl/api/demo/handler/handlers.go delete mode 100644 tools/goctl/api/demo/svc/servicecontext.go diff --git a/tools/goctl/api/demo/config/config.go b/tools/goctl/api/demo/config/config.go deleted file mode 100644 index 5beaa249..00000000 --- a/tools/goctl/api/demo/config/config.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -import "zero/ngin" - -type Config struct { - ngin.NgConf -} diff --git a/tools/goctl/api/demo/demo.go b/tools/goctl/api/demo/demo.go deleted file mode 100644 index 3c203a08..00000000 --- a/tools/goctl/api/demo/demo.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "flag" - - "zero/core/conf" - "zero/ngin" - "zero/tools/goctl/api/demo/config" - "zero/tools/goctl/api/demo/handler" -) - -var configFile = flag.String("f", "etc/user.json", "the config file") - -func main() { - flag.Parse() - - var c config.Config - conf.MustLoad(*configFile, &c) - - engine := ngin.MustNewEngine(c.NgConf) - defer engine.Stop() - - handler.RegisterHandlers(engine) - engine.Start() -} diff --git a/tools/goctl/api/demo/etc/user.json b/tools/goctl/api/demo/etc/user.json deleted file mode 100644 index cd52be6f..00000000 --- a/tools/goctl/api/demo/etc/user.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Name": "user", - "Host": "127.0.0.1", - "Port": 3333, - "Log": { - "Mode": "console" - } -} diff --git a/tools/goctl/api/demo/handler/getuserhandler.go b/tools/goctl/api/demo/handler/getuserhandler.go deleted file mode 100644 index 1baa717c..00000000 --- a/tools/goctl/api/demo/handler/getuserhandler.go +++ /dev/null @@ -1,33 +0,0 @@ -package handler - -import ( - "net/http" - - "zero/ngin/httpx" -) - -type ( - request struct { - User string `form:"user,optional"` - } - - response struct { - Code int `json:"code"` - Greet string `json:"greet"` - From string `json:"from,omitempty"` - } -) - -func GreetHandler(w http.ResponseWriter, r *http.Request) { - var req request - err := httpx.Parse(r, &req) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - httpx.OkJson(w, response{ - Code: 0, - Greet: "hello", - }) -} diff --git a/tools/goctl/api/demo/handler/handlers.go b/tools/goctl/api/demo/handler/handlers.go deleted file mode 100644 index 24e71299..00000000 --- a/tools/goctl/api/demo/handler/handlers.go +++ /dev/null @@ -1,17 +0,0 @@ -package handler - -import ( - "net/http" - - "zero/ngin" -) - -func RegisterHandlers(engine *ngin.Engine) { - engine.AddRoutes([]ngin.Route{ - { - Method: http.MethodGet, - Path: "/", - Handler: GreetHandler, - }, - }) -} diff --git a/tools/goctl/api/demo/svc/servicecontext.go b/tools/goctl/api/demo/svc/servicecontext.go deleted file mode 100644 index 51137699..00000000 --- a/tools/goctl/api/demo/svc/servicecontext.go +++ /dev/null @@ -1,4 +0,0 @@ -package svc - -type ServiceContext struct { -}