Repository: googleapis/genai-toolbox
File: tests/http/http_integration_test.go (Go)

Code before:
		http.NotFound(w, r) // Return 404 for unknown paths
	}
}

// handleQueryTest simply returns the raw query string it received so the test
// can verify it's formatted correctly.
func handleQueryTest(w http.ResponseWriter, r *http.Request) {
    // expect GET method
    if r.Method != http.MethodGet {
        errorMessage := fmt.Sprintf("expected GET method but got: %s", string(r.Method))
        http.Error(w, errorMessage, http.StatusBadRequest)
        return
    }

    w.WriteHeader(http.StatusOK)
    enc := json.NewEncoder(w)
    enc.SetEscapeHTML(false) 

    err := enc.Encode(r.URL.RawQuery)
    if err != nil {
        http.Error(w, "Failed to write response", http.StatusInternalServerError)
        return
    }
}


// handler function for the test server
func handleTool0(w http.ResponseWriter, r *http.Request) {
	// expect POST method
	if r.Method != http.MethodPost {
		errorMessage := fmt.Sprintf("expected POST method but got: %s", string(r.Method))
		http.Error(w, errorMessage, http.StatusBadRequest)
		return
	}
	w.WriteHeader(http.StatusOK)
	response := "hello world"
	err := json.NewEncoder(w).Encode(response)
	if err != nil {
		http.Error(w, "Failed to encode JSON", http.StatusInternalServerError)
		return
	}
}

// handler function for the test server
func handleTool1(w http.ResponseWriter, r *http.Request) {
	// expect GET method
	if r.Method != http.MethodGet {
		errorMessage := fmt.Sprintf("expected GET method but got: %s", string(r.Method))
		http.Error(w, errorMessage, http.StatusBadRequest)
		return
	}

Review comment (suggestion):
```suggestion
}

// handler function for the test server
```

Code after:
		http.NotFound(w, r) // Return 404 for unknown paths
	}
}

// handleQueryTest simply returns the raw query string it received so the test
// can verify it's formatted correctly.
func handleQueryTest(w http.ResponseWriter, r *http.Request) {
    // expect GET method
    if r.Method != http.MethodGet {
        errorMessage := fmt.Sprintf("expected GET method but got: %s", string(r.Method))
        http.Error(w, errorMessage, http.StatusBadRequest)
        return
    }

    w.WriteHeader(http.StatusOK)
    enc := json.NewEncoder(w)
    enc.SetEscapeHTML(false) 

    err := enc.Encode(r.URL.RawQuery)
    if err != nil {
        http.Error(w, "Failed to write response", http.StatusInternalServerError)
        return
    }
}

// handler function for the test server
func handleTool0(w http.ResponseWriter, r *http.Request) {
	// expect POST method
	if r.Method != http.MethodPost {
		errorMessage := fmt.Sprintf("expected POST method but got: %s", string(r.Method))
		http.Error(w, errorMessage, http.StatusBadRequest)
		return
	}
	w.WriteHeader(http.StatusOK)
	response := "hello world"
	err := json.NewEncoder(w).Encode(response)
	if err != nil {
		http.Error(w, "Failed to encode JSON", http.StatusInternalServerError)
		return
	}
}

// handler function for the test server
func handleTool1(w http.ResponseWriter, r *http.Request) {
	// expect GET method
	if r.Method != http.MethodGet {
		errorMessage := fmt.Sprintf("expected GET method but got: %s", string(r.Method))
		http.Error(w, errorMessage, http.StatusBadRequest)
		return
	}
	// Parse request body