speakeasy

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 24 Imported by: 1

README

speakeasy-go-sdk

180100416-b66263e6-1607-4465-b45d-0e298a67c397

Speakeasy is your API Platform team as a service. Use our drop in SDK to manage all your API Operations including embeds for request logs and usage dashboards, test case generation from traffic, and understanding API drift.

The Speakeasy Go SDK for evaluating API requests/responses. Compatible with any API framework implemented on top of Go's native http library.

Requirements

Supported frameworks:

  • gorilla/mux
  • go-chi/chi
  • http.DefaultServerMux

We also support custom Http frameworks:

  • gin-gonic/gin
  • labstack/echo

Usage

Speakeasy uses Go Modules to manage dependencies.

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

Minimum configuration

Sign up for free on our platform. After you've created a workspace and generated an API key enable Speakeasy in your API as follows:

Configure Speakeasy at the start of your main() function with just 2 lines of code:

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

func main() {
	speakeasy.Configure(speakeasy.Configuration {
		APIKey:     "YOUR API KEY HERE",     // retrieve from Speakeasy API dashboard
	})
	// rest of your program.
}

Build and deploy your app and that's it. Your API is being tracked in the Speakeasy workspace you just created and will be visible on the dashboard next time you log in. Visit our docs site to learn more.

Optional Arguments

Coming soon !

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 EchoMiddleware added in v0.0.3

func EchoMiddleware(next echo.HandlerFunc) echo.HandlerFunc

EchoMiddleware setups up the default SDK instance to start capturing requests from the echo http framework.

func GinMiddleware added in v0.0.3

func GinMiddleware(c *gin.Context)

GinMiddleware setups up the default SDK instance to start capturing requests from the gin http framework.

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 from routers that support http.Handlers. Currently only gorilla/mux, go-chi/chi routers and the http.DefaultServerMux are supported for automatically capturing path hints. Otherwise path hints can be supplied by a handler through the speakeasy MiddlewareController.

func MiddlewareController added in v0.0.3

func MiddlewareController(r *http.Request) *controller

MiddlewareController will return the speakeasy middleware controller from the current request, if the current request is monitored by the speakeasy middleware.

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.

func NewCaptureWriter added in v0.0.3

func NewCaptureWriter(origResW http.ResponseWriter, maxBuffer int) *captureWriter

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