fix: reminder工具401认证 — 路由从JWT组迁到internal组
- Gateway新增 /api/v1/internal/reminders (GET/POST/DELETE) - 使用 X-Internal-Token 认证,不再需要JWT - GatewayClient URL改为 /api/v1/internal/reminders Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ type Reminder struct {
|
|||||||
RepeatType string `json:"repeat_type"`
|
RepeatType string `json:"repeat_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateReminder calls POST /api/v1/reminders on the Gateway.
|
// CreateReminder calls POST /api/v1/internal/reminders on the Gateway.
|
||||||
func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, description, remindAt, repeatType, sessionID string) (*Reminder, error) {
|
func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, description, remindAt, repeatType, sessionID string) (*Reminder, error) {
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"user_id": userID,
|
"user_id": userID,
|
||||||
@@ -49,7 +49,7 @@ func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, descr
|
|||||||
}
|
}
|
||||||
reqBody, _ := json.Marshal(body)
|
reqBody, _ := json.Marshal(body)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", c.baseURL+"/api/v1/reminders", bytes.NewReader(reqBody))
|
req, err := http.NewRequestWithContext(ctx, "POST", c.baseURL+"/api/v1/internal/reminders", bytes.NewReader(reqBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -74,9 +74,9 @@ func (c *GatewayClient) CreateReminder(ctx context.Context, userID, title, descr
|
|||||||
return &reminder, nil
|
return &reminder, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListReminders calls GET /api/v1/reminders on the Gateway.
|
// ListReminders calls GET /api/v1/internal/reminders on the Gateway.
|
||||||
func (c *GatewayClient) ListReminders(ctx context.Context, userID, status string, limit int) ([]Reminder, error) {
|
func (c *GatewayClient) ListReminders(ctx context.Context, userID, status string, limit int) ([]Reminder, error) {
|
||||||
url := fmt.Sprintf("%s/api/v1/reminders?user_id=%s&status=%s&limit=%d", c.baseURL, userID, status, limit)
|
url := fmt.Sprintf("%s/api/v1/internal/reminders?user_id=%s&status=%s&limit=%d", c.baseURL, userID, status, limit)
|
||||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -101,9 +101,9 @@ func (c *GatewayClient) ListReminders(ctx context.Context, userID, status string
|
|||||||
return reminders, nil
|
return reminders, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteReminder calls DELETE /api/v1/reminders/:id on the Gateway.
|
// DeleteReminder calls DELETE /api/v1/internal/reminders/:id on the Gateway.
|
||||||
func (c *GatewayClient) DeleteReminder(ctx context.Context, reminderID string) error {
|
func (c *GatewayClient) DeleteReminder(ctx context.Context, reminderID string) error {
|
||||||
req, err := http.NewRequestWithContext(ctx, "DELETE", c.baseURL+"/api/v1/reminders/"+reminderID, nil)
|
req, err := http.NewRequestWithContext(ctx, "DELETE", c.baseURL+"/api/v1/internal/reminders/"+reminderID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user