tadmw

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

tad-middlewares

腾讯广告SDK 中间件

Go Reference Go goreleaser GitHub go.mod Go version of a Go module GoReportCard GitHub license GitHub release

Opentelementry Middleware

import (
  "github.com/tencentad/marketing-api-go-sdk/pkg/ads/v3"
  "github.com/tencentad/marketing-api-go-sdk/pkg/config/v3"
)
func main() {
  tads:= ads.Init(&config.SDKConfig{})
  mw := tadmw.NewOtelMiddlware(clt, "")
  tads.AppendMiddleware(mw)
  // your client id
	clientId := int64(0)
	clientSecret := "your client secret"
	grantType := "authorization_code"
	oauthTokenOpts := &api.OauthTokenOpts{
		AuthorizationCode: optional.NewString("your authorization code"),
		RedirectUri: optional.NewString("your authorization code"),
	}
	ctx := *tads.Ctx
	// oauth/token接口即对应Oauth().Token()方法
	response, _, err := tads.Oauth().Token(ctx, clientId, clientSecret, grantType, oauthTokenOpts)

	if err != nil {
		if resErr, ok := err.(errors.ResponseError); ok {
			errStr, _ := json.Marshal(resErr)
			// TODO for api error
			fmt.Println("Response error:", string(errStr))
		} else {
			// TODO for other error
			fmt.Println("Error:", err)
		}
	}
	tads.SetAccessToken(response.AccessToken)
}

Documentation

Overview

Package tadmw 腾讯广告SDK中间件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OtelMiddleware

type OtelMiddleware struct {
	// contains filtered or unexported fields
}

OtelMiddleware ...

func NewOtelMiddleware

func NewOtelMiddleware(namespace string) *OtelMiddleware

func (*OtelMiddleware) Handle

func (o *OtelMiddleware) Handle(
	req *http.Request,
	next func(req *http.Request) (rsp *http.Response, err error),
) (rsp *http.Response, err error)

Handle ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL