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: 0

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