directory

package
v0.0.0-...-bb60f61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package directory contains logic for serving the homelab index page.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Items []Item `yaml:"items"`
}

The Config type represents the YAML configuration file for links to display on the index page.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig attempts to load the index page configuration located at the provided path. Returns an error if it does not exist or is an invalid YAML configuration.

type HTTP

type HTTP struct {
	transport.HTTP
	// contains filtered or unexported fields
}

The HTTP type is responsible for handling HTTP requests for the index page.

func NewHTTP

func NewHTTP(config *Config) *HTTP

NewHTTP returns a new instance of the HTTP type that will render the index page with the provided configuration items. Items are sorted alphabetically by name.

func (*HTTP) Get

func (t *HTTP) Get(w http.ResponseWriter, r *http.Request)

Get handles an inbound HTTP GET request that renders the index page template with the provided configuration and writes the resulting HTML to the client.

func (*HTTP) Register

func (t *HTTP) Register(r *mux.Router)

Register HTTP handlers on the provided mux.Router.

type Item

type Item struct {
	Name        string `yaml:"name"`
	URL         string `yaml:"url"`
	Description string `yaml:"description"`
}

The Item type represents a single item to display on the index page.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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