mirror of
https://github.com/miniflux/v2.git
synced 2025-07-02 16:38:37 +00:00
Update vendor dependencies
This commit is contained in:
parent
34a3fe426b
commit
459bb4531f
747 changed files with 89857 additions and 39711 deletions
60
vendor/google.golang.org/appengine/remote_api/client.go
generated
vendored
60
vendor/google.golang.org/appengine/remote_api/client.go
generated
vendored
|
@ -27,16 +27,24 @@ import (
|
|||
pb "google.golang.org/appengine/internal/remote_api"
|
||||
)
|
||||
|
||||
// NewRemoteContext returns a context that gives access to the production
|
||||
// APIs for the application at the given host. All communication will be
|
||||
// performed over SSL unless the host is localhost.
|
||||
func NewRemoteContext(host string, client *http.Client) (context.Context, error) {
|
||||
// Client is a connection to the production APIs for an application.
|
||||
type Client struct {
|
||||
hc *http.Client
|
||||
url string
|
||||
appID string
|
||||
}
|
||||
|
||||
// NewClient returns a client for the given host. All communication will
|
||||
// be performed over SSL unless the host is localhost.
|
||||
func NewClient(host string, client *http.Client) (*Client, error) {
|
||||
// Add an appcfg header to outgoing requests.
|
||||
wrapClient := new(http.Client)
|
||||
*wrapClient = *client
|
||||
t := client.Transport
|
||||
if t == nil {
|
||||
t = http.DefaultTransport
|
||||
}
|
||||
client.Transport = &headerAddingRoundTripper{t}
|
||||
wrapClient.Transport = &headerAddingRoundTripper{t}
|
||||
|
||||
url := url.URL{
|
||||
Scheme: "https",
|
||||
|
@ -47,23 +55,35 @@ func NewRemoteContext(host string, client *http.Client) (context.Context, error)
|
|||
url.Scheme = "http"
|
||||
}
|
||||
u := url.String()
|
||||
appID, err := getAppID(client, u)
|
||||
appID, err := getAppID(wrapClient, u)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to contact server: %v", err)
|
||||
}
|
||||
rc := &remoteContext{
|
||||
client: client,
|
||||
url: u,
|
||||
}
|
||||
ctx := internal.WithCallOverride(context.Background(), rc.call)
|
||||
ctx = internal.WithLogOverride(ctx, rc.logf)
|
||||
ctx = internal.WithAppIDOverride(ctx, appID)
|
||||
return ctx, nil
|
||||
return &Client{
|
||||
hc: wrapClient,
|
||||
url: u,
|
||||
appID: appID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type remoteContext struct {
|
||||
client *http.Client
|
||||
url string
|
||||
// NewContext returns a copy of parent that will cause App Engine API
|
||||
// calls to be sent to the client's remote host.
|
||||
func (c *Client) NewContext(parent context.Context) context.Context {
|
||||
ctx := internal.WithCallOverride(parent, c.call)
|
||||
ctx = internal.WithLogOverride(ctx, c.logf)
|
||||
ctx = internal.WithAppIDOverride(ctx, c.appID)
|
||||
return ctx
|
||||
}
|
||||
|
||||
// NewRemoteContext returns a context that gives access to the production
|
||||
// APIs for the application at the given host. All communication will be
|
||||
// performed over SSL unless the host is localhost.
|
||||
func NewRemoteContext(host string, client *http.Client) (context.Context, error) {
|
||||
c, err := NewClient(host, client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.NewContext(context.Background()), nil
|
||||
}
|
||||
|
||||
var logLevels = map[int64]string{
|
||||
|
@ -74,11 +94,11 @@ var logLevels = map[int64]string{
|
|||
4: "CRITICAL",
|
||||
}
|
||||
|
||||
func (c *remoteContext) logf(level int64, format string, args ...interface{}) {
|
||||
func (c *Client) logf(level int64, format string, args ...interface{}) {
|
||||
log.Printf(logLevels[level]+": "+format, args...)
|
||||
}
|
||||
|
||||
func (c *remoteContext) call(ctx context.Context, service, method string, in, out proto.Message) error {
|
||||
func (c *Client) call(ctx context.Context, service, method string, in, out proto.Message) error {
|
||||
req, err := proto.Marshal(in)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshalling request: %v", err)
|
||||
|
@ -97,7 +117,7 @@ func (c *remoteContext) call(ctx context.Context, service, method string, in, ou
|
|||
}
|
||||
|
||||
// TODO(djd): Respect ctx.Deadline()?
|
||||
resp, err := c.client.Post(c.url, "application/octet-stream", bytes.NewReader(req))
|
||||
resp, err := c.hc.Post(c.url, "application/octet-stream", bytes.NewReader(req))
|
||||
if err != nil {
|
||||
return fmt.Errorf("error sending request: %v", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue