callback

package module
v0.0.0-...-1949ccd Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: Apache-2.0 Imports: 10 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

callback GoDoc

Package for dealing with HTTP callbacks to backends

Documentation

Overview

Example
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/orijtech/callback"
)

func main() {
	cb := &callback.Callback{
		URL:     "https://example.com/payload",
		Payload: fmt.Sprintf(`{"time_now": %q}`, time.Now().Round(time.Second)),
	}
	resp, err := cb.Do(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Response: %+v\n", resp)
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
	sync.RWMutex

	URL     string      `json:"url,omitempty"`
	Payload interface{} `json:"payload,omitempty"`

	RoundTripper http.RoundTripper
}

func (*Callback) Do

func (cb *Callback) Do(ctx context.Context) (*http.Response, error)

func (*Callback) Validate

func (cb *Callback) Validate() error

Jump to

Keyboard shortcuts

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