refactor(api): switch to header-based auth for GET requests

- Replace body parsing with header validation for GET endpoints
- Update router to properly handle GET vs POST requests
- Add new ValidateRequestWithHeader function
- Update README to document header requirements
This commit is contained in:
2026-02-27 23:17:18 +08:00
parent 7f54e17bf4
commit 3285e9026a
4 changed files with 69 additions and 24 deletions
+15 -6
View File
@@ -68,6 +68,12 @@ All API responses are returned in JSON format:
}
```
**Important Notes:**
- For **POST** requests: All data is sent in the request body as JSON
- For **GET** requests: All data is sent in HTTP headers (prefixed with `X-`)
- All requests require authentication (except `/register` and `/login`)
- Timestamps are in milliseconds (Unix timestamp)
---
### 1. Register User
@@ -269,13 +275,16 @@ You can modify multiple fields at once:
**Method:** GET
**Auth Required:** Yes (token)
**Request:**
```json
{
"token": "your_token",
"timeStamp": 1704067200000
}
**Request Headers:**
```
X-Token: your_token
X-Timestamp: 1704067200000
```
| Header | Type | Required | Description |
|--------|------|----------|-------------|
| X-Token | string | Yes | Authentication token |
| X-Timestamp | int64 | Yes | Client timestamp in milliseconds |
**Response (admin/superuser):**
```json