server

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package server runs a loopback HTTP server that re-renders Markdown (and neighbouring source files) on demand, so that relative links in the rendered HTML keep working when the user clicks through to another file in the same tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func Start

func Start(rootDir string) (*Server, error)

Start binds a TCP listener on 127.0.0.1 with an OS-assigned port and begins serving. Requests are sandboxed to rootDir (after symlink resolution); any path that escapes the root is rejected with 403. Call Stop to shut down.

func (*Server) OpenInBrowser

func (s *Server) OpenInBrowser(path string) error

OpenInBrowser opens the platform browser pointed at the given file.

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully shuts the server down with a short timeout.

func (*Server) URLFor

func (s *Server) URLFor(path string) (string, error)

URLFor builds the loopback URL that renders the given file. The path is resolved to absolute form and symlinks are followed so the URL matches where the file actually lives; relative links inside the rendered HTML then resolve relative to the real file's directory rather than the symlink's parent. If the file does not exist (e.g. a URL for a broken link the caller still wants to fetch), the parent directory is canonicalised instead so the resulting URL still survives the server's lexical sandbox check.

Jump to

Keyboard shortcuts

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