A:增加HTTP基础功能的访问和HTTP模板
This commit is contained in:
1 parent
e4de5917cd
commit
f67e27320f
11 files changed
+620
-6
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"rear/internal/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Config 配置结构
|
||||
type Config struct {
|
||||
Port string
|
||||
Mode string
|
||||
ReadTimeout time.Duration
|
||||
WriteTimeout time.Duration
|
||||
IdleTimeout time.Duration
|
||||
}
|
||||
|
||||
// InitConfig 初始化配置
|
||||
func InitConfig() *Config {
|
||||
return &Config{
|
||||
Port: utils.GetEnv("PORT", "8080"),
|
||||
Mode: utils.GetEnv("GIN_MODE", "debug"),
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 30 * time.Second,
|
||||
IdleTimeout: 60 * time.Second,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package model
|
||||
|
||||
// Response 统一响应结构
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package model
|
||||
|
||||
// User 示例用户结构
|
||||
type User struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
Reference in new issue
Block a user