s3cache

package module
v0.0.0-...-0490858 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2018 License: MIT Imports: 14 Imported by: 0

README

GoDoc Build Status Coverage Status Go Report Card

autocert-s3-cache

AWS S3 cache for acme/autocert written in Go.

Example

cache, err := s3cache.New("eu-west-1", "my-bucket")
if err != nil {
  // Handle error
}

m := autocert.Manager{
  Prompt:     autocert.AcceptTOS,
  HostPolicy: autocert.HostWhitelist("example.org"),
  Cache:      cache,
}

s := &http.Server{
  Addr:      ":https",
  TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
}

s.ListenAndServeTLS("", "")

Documentation

Overview

package s3cache implements a https://godoc.org/golang.org/x/crypto/acme/autocert Cache to store keys within in a S3 bucket. If the key does not exist, it will be created automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Logger Logger
	// contains filtered or unexported fields
}

Cache provides a s3 backend to the autocert cache.

func New

func New(region, bucket string, opts ...OptFunc) (*Cache, error)

New creates an s3 interface to the autocert cache.

func NewDSN

func NewDSN(dsn string, opts ...OptFunc) (*Cache, error)

NewDSN returns a s3 interface to the autocert cache based on a standard S3 DSN. The path cannot be overwritten

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete removes a certificate data from the cache under the specified key.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) ([]byte, error)

Get returns a certificate data for the specified key.

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, key string, data []byte) error

Put stores the data in the cache under the specified key.

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger for outputing logs

type OptFunc

type OptFunc func(*options)

OptFunc is for options passed in to New

func KeyPrefix

func KeyPrefix(prefix string) OptFunc

KeyPrefix adds an S3 key prefix to the certs stored

func UserPass

func UserPass(id, secret string) OptFunc

Jump to

Keyboard shortcuts

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