server

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package server provides the HTTP server for the WikiMD web application.

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
}

Server wraps the HTTP server and configuration for serving markdown content over HTTP. It provides a RESTful API for reading, creating, updating, and deleting markdown documents, along with a web interface for browsing the wiki.

func New

func New(cfg config.Config, logger *slog.Logger, contentSvc *content.Service, searchSvc *search.Service) (*Server, error)

New constructs a new Server with the provided configuration and services. It initializes the HTTP server, registers all routes and middleware, and prepares the server for starting via the Start method. Returns an error if template loading or exporter initialization fails.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server with the provided context timeout. It waits for all active connections to close or the context to be canceled. Returns an error if the shutdown process fails or times out.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start runs the HTTP server and optionally opens the browser. The server will listen on the configured port (or allocate a dynamic port if cfg.Port is 0). It supports graceful shutdown when the provided context is canceled. The method blocks until the server stops or an error occurs.

Jump to

Keyboard shortcuts

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