Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 965 Bytes

README.md

File metadata and controls

33 lines (23 loc) · 965 Bytes

certmagic-badgerstorage

Package badgerstorage implements a certmagic.Storage on top of a Badger database.

It's an alternative to the default file-system storage used by CertMagic.

Install

go get oya.to/certmagic-badgerstorage

Usage

package main

import (
	"github.com/caddyserver/certmagic"
	"github.com/dgraph-io/badger/v2"
	"log"
	"oya.to/certmagic-badgerstorage"
)

func main() {
	// setup the badger DB
	db, err := badger.Open(badger.DefaultOptions("").WithInMemory(true))
	if err != nil {
		log.Fatalf("Cannot open badger memory DB: %s", err)
	}

	// set the default CertMagic storage to replace the file-system based on.
	certmagic.Default.Storage = badgerstorage.New(db)

	// setup the rest of your CertMagic stuff...
}