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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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