Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang_framework_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
69909ab5
authored
Oct 13, 2021
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
5e573699
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
5 deletions
README.md
boot/http/boot.go
config/dev/proxy.toml
router/httpserver.go
README.md
View file @
69909ab5
...
...
@@ -75,6 +75,52 @@ go run ./cmd/task/main.go -config=./config/dev/ -logdir=./logs/
├── go.mod
启动须知:
修改config/proxy.toml
修改启动端口:
[
http
]
addr =":8700" # 监听地址, default ":8700"
read_timeout = 10 # 读取超时时长
write_timeout = 10 # 写入超时时长
max_header_bytes = 20 # 最大的header大小,二进制位长度
微服务注册相关信息修改
#服务注册名称
micro_service_name = "golang_async_task_http"
#etcd配置信息 etcd服务的ip端口用户密码
[
etcd_config
]
addrs =
[
"192.168.1.252:2379"
]
username = ""
password = ""
#注册到etcd中的ip 端口 权重信息
[
etcd_regist
]
ip = "192.168.1.252"
port = 60020
weight = 10
参考文献:
xorm:https://www.kancloud.cn/xormplus/xorm/413729
...
...
boot/http/boot.go
View file @
69909ab5
...
...
@@ -10,7 +10,7 @@ func Init(configPath string,logPath string)(err error){
if
err
!=
nil
{
panic
(
err
)
}
xlog
.
Init
(
logPath
,
"http"
)
xlog
.
Init
(
logPath
,
"http"
,
"request"
)
//初始化数据库
http
.
Init
()
...
...
config/dev/proxy.toml
View file @
69909ab5
...
...
@@ -11,7 +11,7 @@ micro_service_name = "golang_async_task_http"
#注册到etcd中的ip 端口 权重信息
[etcd_regist]
ip
=
"192.168.1.
168
"
ip
=
"192.168.1.
252
"
port
=
60020
weight
=
10
...
...
@@ -23,7 +23,7 @@ micro_service_name = "golang_async_task_http"
time_location
=
"Asia/Chongqing"
[http]
addr
=
"
192.168.1.168:8700"
# 监听地址, default ":8700"
addr
=
"
:8700"
# 监听地址, default ":8700"
read_timeout
=
10
# 读取超时时长
write_timeout
=
10
# 写入超时时长
max_header_bytes
=
20
# 最大的header大小,二进制位长度
router/httpserver.go
View file @
69909ab5
...
...
@@ -23,8 +23,8 @@ func HttpServerRun() {
gin
.
SetMode
(
cfg
.
Instance
(
"proxy"
)
.
GetString
(
"base.debug_mode"
))
r
:=
InitRouter
(
//
middleware.RequestLog(),
middleware
.
AuthMiddleware
(),
middleware
.
RequestLog
(),
//
middleware.AuthMiddleware(),
middleware
.
RecoveryMiddleware
(),
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment