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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user