middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 3 Imported by: 0

README

Retry example

A middleware to retry failed API requests 3 times with a 1 second timeout.

package main

import (
    "time"

    sdkutil "github.com/tdakkota/vksdkutil"
    "github.com/tdakkota/vksdkutil/middleware"
)

func main() {
    n, timeout := 3, time.Second
    vk := sdkutil.BuildSDK("token").
        WithMiddleware(middleware.Retry(n, timeout)).
        Complete()
    // ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteParams

func DeleteParams(list []string) func(handler sdkutil.Handler) sdkutil.Handler

DeleteParams is middleware which deletes query params from list. It's useful for API proxy.

func Retry

func Retry(maxAttempts int, timeout time.Duration) func(handler sdkutil.Handler) sdkutil.Handler

Retry is middleware which retries requests if underlying handler fails.

Types

This section is empty.

Directories

Path Synopsis
log
zap

Jump to

Keyboard shortcuts

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