speakeasy

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

README

speakeasy-go-sdk

Go SDK for parsing API requests and responses for any API framework using native http library

Installation

go get github.com/speakeasy-api/speakeasy-go-sdk

Speakeasy uses Go Modules to manage dependencies.

Basic configuration

Configure Speakeasy at the start of your main() function:

import "github.com/speakeasy-api/speakeasy-go-sdk"

func main() {
	speakeasy.Configure(speakeasy.Configuration{
		APIKey:     "YOUR API KEY HERE",     // retrieve from future Speakeasy dev dashboard
		ProjectID:  "YOUR WORKSPACE ID HERE" // workspace id
		KeysToMask: []string{"password"},    // optional, mask fields you don't want sent to Speakeasy
		ServerURL:  "localhost://3000",      // optional, don't use default server URL
	}

    // rest of your program.
}

After that, just use the middleware with any of your handlers:

mux := http.NewServeMux()
mux.Handle("/", speakeasy.Middleware(yourHandler))

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAPIKeyMissing = errors.New("API key is required")

ErrAPIKeyMissing is returned when the API Key is not provided at configuration time.

Functions

func Configure

func Configure(config Config)

Configure allows you to configure the default instance of the Speakeasy SDK. Use this if you will use the same API Key for all connected APIs.

func Middleware added in v0.0.1

func Middleware(next http.Handler) http.Handler

Middleware setups up the default SDK instance to start capturing requests.

func New added in v0.0.1

func New(config Config) *speakeasy

New creates a new instance of the Speakeasy SDK. This allows you to create multiple instances of the SDK for specifying different API Keys for different APIs.

Types

type Config

type Config struct {
	APIKey     string
	GRPCDialer func() func(context.Context, string) (net.Conn, error)
}

Config provides configuration for the Speakeasy SDK.

Directories

Path Synopsis
internal
log

Jump to

Keyboard shortcuts

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