static

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

static

Static File Handler from a filesystem. For example:

package main

import (
    "github.com/mutablelogic/go-server/pkg/httpserver"
)

func main() {
    static, err := static.Config{FS: os.DirFS("/"), Dir: true}.New(context.Background())
    if err != nil {
        log.Fatal(err)
    }
    // ...
}

Passing Dir as true will serve a basic directory listing for a filesystem. If Dir is false, then the handler will serve files from the directory FS only, and serve the index.html file is lieu of a directory, if it exists.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	FS   fs.FS  `hcl:"fs" description:"File system to serve"`
	Dir  bool   `hcl:"dir" description:"Serve directory listings"`
	Host string `hcl:"host" description:"Host to serve files on"`
}

func (Config) Description

func (Config) Description() string

Description returns the description of the service

func (Config) Name

func (Config) Name() string

Name returns the name of the service

func (Config) New

func (c Config) New() (server.Task, error)

Create a new static handler from the configuration

Jump to

Keyboard shortcuts

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