mddocdb

package module
v0.0.0-...-43fd2fb Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 10 Imported by: 0

README

go-mddocdb

build

go-mddocdb takes an interface to a file system and returns an http.handler. When a request comes in (e.g. /example) it'll try to read the appropriate file (/example.md) from the file system - if it finds it, it'll turn it from markdown into html. It does some in memory caching.

mddocdb.NewHandler(
    fs, // the filesystem to read from, which should include a 'get' that returns back a reader
    "", // the basepath to ignore
    &mddocdb.Options{
        CacheDurationSeconds: 300, // how long to keep the cache around for
        Template: ..., // the template to use for the html page
    },
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHandler

func GetHandler(fs FS, basepath string, opts *Options) http.Handler

Types

type CachedDocument

type CachedDocument struct {
	Key       string
	Document  []byte
	CreatedAt time.Time
}

type FS

type FS interface {
	OpenRead(key string) (io.Reader, error)
}

type Options

type Options struct {
	CacheDuration time.Duration
	Template      *template.Template
	Logger        *log.Logger
}

Jump to

Keyboard shortcuts

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