Files
platforms/sample/server/README.md

32 lines
868 B
Markdown
Raw Normal View History

2026-07-27 00:18:42 +08:00
# Sample Server
2026-07-27 00:18:42 +08:00
基于 BSM-SDK Core 的 Go 服务样例,展示 Gin HTTP 服务、配置管理、GORM 数据库访问、Redis 缓存、JWT 鉴权与分层架构。
2026-07-27 00:18:42 +08:00
## 功能
2026-07-27 00:18:42 +08:00
- `HEAD /``GET /Sample/v1/ping/hello` 健康检查。
- `Sample/v1/sample/demo` 示例 CRUD。
- 模型在应用启动时由 GORM 自动同步数据库结构。
- `go run ./cmd/cli/main.go version` 查看 CLI 版本。
2026-07-27 00:18:42 +08:00
## 启动
```bash
cp etc/sample_dev.yaml.example etc/sample_dev.yaml
export BSM_RuntimeMode=dev
export BSM_Prefix=$(pwd)/etc
export BSM_JwtSecretKey=your-secret-key
2026-07-27 00:18:42 +08:00
go run ./cmd/main/main.go
```
2026-07-27 00:18:42 +08:00
Windows PowerShell 使用:
2026-07-27 00:18:42 +08:00
```powershell
$env:BSM_RuntimeMode="dev"
$env:BSM_Prefix="$(Get-Location)/etc"
$env:BSM_JwtSecretKey="your-secret-key"
go run ./cmd/main/main.go
```
2026-07-27 00:18:42 +08:00
服务默认监听 `12426`,可访问 `http://127.0.0.1:12426/Sample/v1/ping/hello`