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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址