client

package
v0.0.0-...-5a03b40 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 10 Imported by: 0

README

client

Package client implements a Go client for purgery.

Usage

package main

import (
	"context"
	"log"

	"github.com/soupedup/purgery/pkg/client"
)

func main() {
	purgery := client.New("http://localhost:7979", "my-api-key")

	if err := purgery.Purge(context.TODO(), "http://google.com"); err != nil {
		log.Fatalf("failed purging: %v", err)
	}
}

Documentation

Overview

Package client implements a purgery client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements a Purgery client.

Instances of Client are safe for concurrent use.

func New

func New(rootURL, apiKey string) *Client

New initializes and returns a Purgery client for the purgery API running at the given API root URL.

In case the given apiKey isn't empty, the client will use HTTP Basic Authorization when interacting with the API.

func (*Client) Purge

func (c *Client) Purge(ctx context.Context, url string) (err error)

Purge requests that the given URL be purged from the remote cache.

func (*Client) RootURL

func (c *Client) RootURL() string

RootURL returns the root URL of the API the Client is configured to run against.

Jump to

Keyboard shortcuts

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