初始提交
This commit is contained in:
38
golang-learning/10-projects/03-web-server/README.md
Normal file
38
golang-learning/10-projects/03-web-server/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Web 服务器项目
|
||||
|
||||
一个简单的 HTTP Web 服务器,提供 RESTful API。
|
||||
|
||||
## 功能特性
|
||||
- HTTP 服务器
|
||||
- RESTful API 端点
|
||||
- JSON 数据处理
|
||||
- 路由处理
|
||||
- 中间件支持
|
||||
- 静态文件服务
|
||||
|
||||
## API 端点
|
||||
- `GET /` - 首页
|
||||
- `GET /api/users` - 获取用户列表
|
||||
- `POST /api/users` - 创建新用户
|
||||
- `GET /api/users/{id}` - 获取特定用户
|
||||
- `PUT /api/users/{id}` - 更新用户
|
||||
- `DELETE /api/users/{id}` - 删除用户
|
||||
|
||||
## 运行方法
|
||||
```bash
|
||||
cd 03-web-server
|
||||
go run main.go
|
||||
```
|
||||
|
||||
服务器将在 http://localhost:8080 启动
|
||||
|
||||
## 使用示例
|
||||
```bash
|
||||
# 获取用户列表
|
||||
curl http://localhost:8080/api/users
|
||||
|
||||
# 创建新用户
|
||||
curl -X POST http://localhost:8080/api/users \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"张三","email":"zhangsan@example.com"}'
|
||||
```
|
Reference in New Issue
Block a user