refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -67,9 +67,9 @@ func (h *WSHandler) HandleWebSocket(c *gin.Context) {
|
||||
if token == "" {
|
||||
authHeader := c.GetHeader("Authorization")
|
||||
if authHeader != "" {
|
||||
parts := strings.SplitN(authHeader, " ", 2)
|
||||
if len(parts) == 2 && parts[0] == "Bearer" {
|
||||
token = parts[1]
|
||||
prefix, rest, found := strings.Cut(authHeader, " ")
|
||||
if found && prefix == "Bearer" {
|
||||
token = rest
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ func (h *WSHandler) handleCallInvite(ctx context.Context, client *ws.Client, pay
|
||||
EventID: h.wsHub.NextID(),
|
||||
Type: "call_invited",
|
||||
TS: time.Now().UnixMilli(),
|
||||
Payload: map[string]interface{}{
|
||||
Payload: map[string]any{
|
||||
"call_id": call.ID,
|
||||
"conversation_id": req.ConversationID,
|
||||
"callee_id": req.CalleeID,
|
||||
@@ -528,7 +528,7 @@ func (h *WSHandler) handleCallAnswer(ctx context.Context, client *ws.Client, pay
|
||||
EventID: h.wsHub.NextID(),
|
||||
Type: "call_accepted",
|
||||
TS: time.Now().UnixMilli(),
|
||||
Payload: map[string]interface{}{
|
||||
Payload: map[string]any{
|
||||
"call_id": call.ID,
|
||||
"started_at": call.StartedAt,
|
||||
},
|
||||
@@ -582,7 +582,7 @@ func (h *WSHandler) handleCallSDP(ctx context.Context, client *ws.Client, payloa
|
||||
return
|
||||
}
|
||||
|
||||
signalPayload, _ := json.Marshal(map[string]interface{}{
|
||||
signalPayload, _ := json.Marshal(map[string]any{
|
||||
"sdp_type": req.SDPType,
|
||||
"sdp": json.RawMessage(req.SDP),
|
||||
})
|
||||
@@ -602,7 +602,7 @@ func (h *WSHandler) handleCallICE(ctx context.Context, client *ws.Client, payloa
|
||||
return
|
||||
}
|
||||
|
||||
signalPayload, _ := json.Marshal(map[string]interface{}{
|
||||
signalPayload, _ := json.Marshal(map[string]any{
|
||||
"candidate": json.RawMessage(req.Candidate),
|
||||
})
|
||||
if err := h.callService.RelaySignal(ctx, req.CallID, client.UserID, "call_ice", signalPayload); err != nil {
|
||||
@@ -631,7 +631,7 @@ func (h *WSHandler) handleCallEnd(ctx context.Context, client *ws.Client, payloa
|
||||
EventID: h.wsHub.NextID(),
|
||||
Type: "call_ended",
|
||||
TS: time.Now().UnixMilli(),
|
||||
Payload: map[string]interface{}{
|
||||
Payload: map[string]any{
|
||||
"call_id": call.ID,
|
||||
"duration": call.Duration,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user