Implement an API-first Go rewrite with local engine adapters, upstream fallback, and Nix-based tooling so searches can run without matching the original UI while preserving response compatibility. Made-with: Cursor
26 lines
510 B
Go
26 lines
510 B
Go
package engines
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
type roundTripperFunc func(*http.Request) (*http.Response, error)
|
|
|
|
func (f roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) {
|
|
return f(r)
|
|
}
|
|
|
|
func httpResponse(status int, body string, contentType string) *http.Response {
|
|
h := make(http.Header)
|
|
if contentType != "" {
|
|
h.Set("Content-Type", contentType)
|
|
}
|
|
return &http.Response{
|
|
StatusCode: status,
|
|
Header: h,
|
|
Body: io.NopCloser(strings.NewReader(body)),
|
|
}
|
|
}
|
|
|