gcscache

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

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

Go to latest
Published: Sep 3, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

README

GCS Cache

Go Report Card GoDoc

GCS Cache implements the autocet.Cache interface using Google Cloud Storage.

Example Usage

package main

import (
    "crypto/tls"
    "log"
    "net/http"

    "github.com/kelseyhightower/gcscache"
    "golang.org/x/crypto/acme/autocert"
)

func main() {
    cache, err := gcscache.New("bucket")
    if err != nil {
        log.Fatal(err)
    }

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

    mux := http.NewServeMux()
    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Autocert with Google Cloud Storage Cache"))
    })

    s := &http.Server{
        Addr:      "0.0.0.0:443",
        Handler:   mux,
        TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
    }

    s.ListenAndServeTLS("", "")
}

Documentation

Overview

Package gcscache provides storage, backed by Google Cloud Storage, for certificates managed by the golang.org/x/crypto/acme/autocert package.

This package is a work in progress and makes no API stability promises.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache implements the autocert.Cache interface using Google Cloud Storage.

func New

func New(bucket string) (*Cache, error)

func (*Cache) Delete

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

Delete removes the specified object name.

func (*Cache) Get

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

Get reads a certificate data from the specified object name.

func (*Cache) Put

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

Put writes the certificate data to the specified object name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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