@@ -44,6 +44,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
44
44
case "/api/clear" :
45
45
h .handleClearRequests (w , r )
46
46
return
47
+ case "/api/compare" :
48
+ h .handleCompareRequests (w , r )
49
+ return
47
50
case "/" :
48
51
h .handleDashboard (w , r )
49
52
return
@@ -156,6 +159,37 @@ func (h *Handler) handleSSE(w http.ResponseWriter, r *http.Request) {
156
159
}
157
160
}
158
161
162
+ // handleCompareRequests serves the JSON API for comparing specific requests
163
+ func (h * Handler ) handleCompareRequests (w http.ResponseWriter , r * http.Request ) {
164
+ w .Header ().Set ("Content-Type" , "application/json" )
165
+
166
+ // Get request IDs from query parameters
167
+ ids := r .URL .Query ()["id" ]
168
+ if len (ids ) < 2 {
169
+ http .Error (w , "At least two request IDs are required" , http .StatusBadRequest )
170
+ return
171
+ }
172
+
173
+ // Get all requests
174
+ allRequests := h .store .GetAll ()
175
+
176
+ // Filter requests by IDs
177
+ compareRequests := []interface {}{}
178
+ for _ , req := range allRequests {
179
+ for _ , id := range ids {
180
+ if req .ID == id {
181
+ compareRequests = append (compareRequests , req )
182
+ break
183
+ }
184
+ }
185
+ }
186
+
187
+ // Return the filtered requests
188
+ encoder := json .NewEncoder (w )
189
+ encoder .SetEscapeHTML (false )
190
+ encoder .Encode (compareRequests )
191
+ }
192
+
159
193
// isSensitiveEnvVar returns true if the environment variable key is considered sensitive
160
194
func isSensitiveEnvVar (key string ) bool {
161
195
sensitiveKeys := []string {
0 commit comments