github.com/instill-ai/component@v0.16.0-beta/pkg/connector/restapi/v0/client.go (about) 1 package restapi 2 3 import ( 4 "github.com/instill-ai/component/pkg/connector/util/httpclient" 5 "go.uber.org/zap" 6 "google.golang.org/protobuf/types/known/structpb" 7 ) 8 9 type TaskInput struct { 10 EndpointURL string `json:"endpoint_url"` 11 Body interface{} `json:"body,omitempty"` 12 } 13 14 type TaskOutput struct { 15 StatusCode int `json:"status_code"` 16 Body interface{} `json:"body"` 17 Header map[string][]string `json:"header"` 18 } 19 20 func newClient(config *structpb.Struct, logger *zap.Logger) (*httpclient.Client, error) { 21 c := httpclient.New("REST API", "", 22 httpclient.WithLogger(logger), 23 ) 24 25 auth, err := getAuthentication(config) 26 if err != nil { 27 return nil, err 28 } 29 30 if err := auth.setAuthInClient(c); err != nil { 31 return nil, err 32 } 33 34 return c, nil 35 }