mdhttp

package module
v0.0.0-...-20f67df Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 9 Imported by: 0

README

go-mdhttp

Package mdhttp provides an http.Handler middleware to render markdown to HTML, for the Go programming language.

mdhttp only renders markdown to HTML when the nested http.Handler returns something with a Content-Type of text/markdown AND the Accept header in the HTTP request does NOT contain text/markdown.

mdhttp uses goldmark.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-mdhttp

GoDoc

Example

Here is an example of using mdhttp.Handler to wrap another handler, to provide mardown to HTML rendering.

import "codeberg.org/reiver/go-mdhttp"

// ...

var handler http.Handler = ...

handler = mdhttp.Wrap(handler) // <---------

err := http.ListenAndServe(":8080", handler)
if nil != err {
	return err
}

Import

To import package mdhttp use import code like the following:

import "codeberg.org/reiver/go-mdhttp"

Installation

To install package mdhttp do the following:

GOPROXY=direct go get codeberg.org/reiver/go-mdhttp

Author

Package mdhttp was written by Charles Iliya Krempeaux

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(subHandler http.Handler, options ...goldmark.Option) http.Handler

Wrap provides http.Handler middleware. It wraps another http.Handler and renders markdown it returns under the correct conditions.

The correct conditions for rendering **markdown** as **HTML** is when the nested http.Handler returns something with a `Content-Type` of `text/markdown` AND the `Accept` header in the HTTP request does NOT contain `text/markdown`.

func WrapHTML

func WrapHTML(htmlPrefix func([]byte, io.Writer), htmlSuffix func([]byte, io.Writer), subHandler http.Handler, options ...goldmark.Option) http.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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