mirror of
https://github.com/karust/openserp.git
synced 2026-08-05 16:53:54 +08:00
fix(ecosia): wire proxy policy, validation, raw mode, and OpenAPI docs
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
[](https://hub.docker.com/repository/docker/karust/openserp)
|
||||
[](https://github.com/karust/openserp/actions/workflows/ci.yml)
|
||||
|
||||
**OpenSERP** is an API and CLI for accessing search engine results from **Google, Yandex, Baidu, Bing, and DuckDuckGo**.
|
||||
**OpenSERP** is an API and CLI for accessing search engine results from **Google, Yandex, Baidu, Bing, DuckDuckGo, and Ecosia**.
|
||||
A developer-friendly alternative to paid SERP API services!
|
||||
|
||||
**Official website:** [openserp.org](https://openserp.org)
|
||||
@@ -53,7 +53,7 @@ go build -o openserp .
|
||||
|
||||
## Search Endpoints
|
||||
|
||||
Available engine names: `google`, `yandex`, `baidu`, `bing`, `duckduckgo`.
|
||||
Available engine names: `google`, `yandex`, `baidu`, `bing`, `duckduckgo`, `ecosia`.
|
||||
|
||||
Dedicated engine endpoints:
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ func buildEngineProxyPolicyMap() map[string]string {
|
||||
"baidu": config.BaiduConfig.Proxy,
|
||||
"bing": config.BingConfig.Proxy,
|
||||
"duckduckgo": config.DuckDuckGoConfig.Proxy,
|
||||
"ecosia": config.EcosiaConfig.Proxy,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version = "0.7.7"
|
||||
version = "0.7.8"
|
||||
defaultConfigFilename = "config"
|
||||
envPrefix = "OPENSERP"
|
||||
)
|
||||
@@ -317,7 +317,7 @@ func initializeConfig(cmd *cobra.Command) error {
|
||||
}
|
||||
|
||||
func validateEngineProxyTags(v *viper.Viper) error {
|
||||
for _, engineName := range []string{"google", "yandex", "baidu", "bing", "duckduckgo"} {
|
||||
for _, engineName := range []string{"google", "yandex", "baidu", "bing", "duckduckgo", "ecosia"} {
|
||||
key := engineName + ".proxy"
|
||||
if !v.IsSet(key) {
|
||||
continue
|
||||
|
||||
@@ -39,6 +39,8 @@ func (r *rawEngine) Search(ctx context.Context, q core.Query) ([]core.SearchResu
|
||||
return yandex.Search(ctx, q)
|
||||
case "baidu":
|
||||
return baidu.Search(ctx, q)
|
||||
case "ecosia":
|
||||
return ecosia.Search(ctx, q)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported engine: %s", r.name)
|
||||
}
|
||||
@@ -102,6 +104,7 @@ func serve(cmd *cobra.Command, args []string) {
|
||||
&rawEngine{name: "google"},
|
||||
&rawEngine{name: "yandex"},
|
||||
&rawEngine{name: "baidu"},
|
||||
&rawEngine{name: "ecosia"},
|
||||
)
|
||||
if err := listenWithGracefulShutdown(serv, nil); err != nil {
|
||||
logrus.Error(err)
|
||||
|
||||
@@ -32,7 +32,7 @@ paths:
|
||||
operationId: searchWeb
|
||||
summary: Search web results from a specific engine
|
||||
description: >
|
||||
Engine path values are `google`, `yandex`, `baidu`, `bing`, and `duck`
|
||||
Engine path values are `google`, `yandex`, `baidu`, `bing`, `duck`, and `ecosia`
|
||||
(`duck` maps to DuckDuckGo internally). Use `?format=markdown|text|ndjson`
|
||||
for alternative output formats.
|
||||
parameters:
|
||||
@@ -487,7 +487,7 @@ components:
|
||||
description: Search engine endpoint alias (`duck` is DuckDuckGo).
|
||||
schema:
|
||||
type: string
|
||||
enum: [google, yandex, baidu, bing, duck]
|
||||
enum: [google, yandex, baidu, bing, duck, ecosia]
|
||||
TextQuery:
|
||||
name: text
|
||||
in: query
|
||||
|
||||
Reference in New Issue
Block a user