From 3918c6726bf7e68bb7a0eeef2539443448c74cc4 Mon Sep 17 00:00:00 2001 From: viletyy Date: Sun, 20 Jun 2021 22:28:27 +0800 Subject: [PATCH] add: generate scripts --- initialize/http_server.go | 28 ++++++++++++++++++++++++++++ scripts/gen_basic_proto.sh | 9 +++++++++ scripts/gen_proto.sh | 9 +++++++++ 3 files changed, 46 insertions(+) create mode 100644 initialize/http_server.go create mode 100644 scripts/gen_basic_proto.sh create mode 100644 scripts/gen_proto.sh diff --git a/initialize/http_server.go b/initialize/http_server.go new file mode 100644 index 0000000..d5f3271 --- /dev/null +++ b/initialize/http_server.go @@ -0,0 +1,28 @@ +/* + * @Date: 2021-03-22 17:03:27 + * @LastEditors: viletyy + * @LastEditTime: 2021-06-20 22:22:10 + * @FilePath: /potato/initialize/http_server.go + */ +package initialize + +import ( + "net/http" + "time" + + "github.com/viletyy/potato/global" + "github.com/viletyy/potato/internal/routers" +) + +func RunHttpServer(port string) *http.Server { + router := routers.InitRouter() + server := &http.Server{ + Addr: port, + Handler: router, + ReadTimeout: time.Duration(global.GO_CONFIG.Server.ReadTimeout) * time.Second, + WriteTimeout: time.Duration(global.GO_CONFIG.Server.ReadTimeout) * time.Second, + MaxHeaderBytes: 1 << 20, + } + + return server +} diff --git a/scripts/gen_basic_proto.sh b/scripts/gen_basic_proto.sh new file mode 100644 index 0000000..c20e198 --- /dev/null +++ b/scripts/gen_basic_proto.sh @@ -0,0 +1,9 @@ +### + # @Date: 2021-06-20 21:43:20 + # @LastEditors: viletyy + # @LastEditTime: 2021-06-20 22:24:50 + # @FilePath: /potato/scripts/gen_basic_proto.sh +### +protoc --go_out=. --go_opt=paths=source_relative \ +--go-grpc_out=. --go-grpc_opt=paths=source_relative \ +./proto/basic/*.proto \ No newline at end of file diff --git a/scripts/gen_proto.sh b/scripts/gen_proto.sh new file mode 100644 index 0000000..c44aa75 --- /dev/null +++ b/scripts/gen_proto.sh @@ -0,0 +1,9 @@ +### + # @Date: 2021-06-20 21:43:20 + # @LastEditors: viletyy + # @LastEditTime: 2021-06-20 22:23:27 + # @FilePath: /potato/scripts/gen_proto.sh +### +protoc --go_out=. --go_opt=paths=source_relative \ +--go-grpc_out=. --go-grpc_opt=paths=source_relative \ +./proto/*.proto \ No newline at end of file