recipes

package module
v0.0.0-...-4ff7096 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: AGPL-3.0 Imports: 12 Imported by: 1

README

Recipe Handler

This is a simple HTTP handler library that's meant to serve static recipe pages. I made this for myself because I wanted something custom to my needs without extra bloat and fanciness. It serves recipes formatted in markdown from a provided directory.

This repo also contains barebones example server whose only handler is the recipe handler. The exmaple server listens on port 8080.

go run example/main.go /path/to/your/recipe/folder

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRecipeTemplate     = template.Must(template.New("").Parse(recipeTmplText))
	DefaultRecipeListTemplate = template.Must(template.New("").Parse(recipeListTmplText))
)

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Path of the recipe directory
	Path string
	// Template to be used for rendering a recipe page. Each recipe page uses the
	// Page struct for its data.
	RecipePageTemplate *template.Template
	// Template to be used for rendering a recipe list page (i.e. a directory).
	RecipeListTemplate *template.Template
}

Handler is a HTTP handler for serving a recipes directory.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Page

type Page struct {
	Title string
	Body  template.HTML
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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