Help us shape the future of Go! Take the 2026 Go Developer Survey

golang-server-static

command module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 2 Imported by: 0

README

golang-server-static

Http helper for static files

How to use

go get github.com/vladimirok5959/golang-server-static
package main

import (
	"net/http"

	"github.com/vladimirok5959/golang-server-static/static"
)

func main() {
	stat := static.New("index.html")
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if stat.Response("./htdocs", w, r, nil, nil) {
			return
		}
		w.WriteHeader(http.StatusNotFound)
		w.Header().Set("Content-Type", "text/html; charset=utf-8")
		w.Write([]byte(`<div>Error 404!</div>`))
	})

	http.ListenAndServe(":8080", nil)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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