fix error response for web APIs

This commit is contained in:
ginuerzh
2024-06-04 22:05:13 +08:00
parent 754b2fdeac
commit 118ee91c95
31 changed files with 730 additions and 249 deletions

View File

@ -33,6 +33,7 @@ func NewGRPCPlugin(name string, addr string, opts ...plugin.Option) observer.Obs
conn, err := plugin.NewGRPCConn(addr, &options)
if err != nil {
log.Error(err)
return nil
}
p := &grpcPlugin{

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/go-gost/core/logger"
"github.com/go-gost/core/observer"
@ -58,6 +59,9 @@ func NewHTTPPlugin(name string, url string, opts ...plugin.Option) observer.Obse
opt(&options)
}
if !strings.HasPrefix(url, "http") {
url = "http://" + url
}
return &httpPlugin{
url: url,
client: plugin.NewHTTPClient(&options),