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

knight

package module
v0.0.0-...-f9e6096 Latest Latest
Warning

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

Go to latest
Published: May 21, 2014 License: BSD-3-Clause Imports: 10 Imported by: 1

README

knight

One HTTP web server with reloader for Go, knight detects file changes and restart the server automatically.

##install

$ go get github.com/fengsp/knight

##usage Basically you just need to set one watching path.

package main
    
import (
    "fmt"
    "net/http"
    "github.com/fengsp/knight"
)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "It works!")
}

func main() {
    http.HandleFunc("/", handler)
    // pass your root path in
    // pass "" to use current working directory
    knight := knight.NewKnight("/private/tmp/test")
    knight.ListenAndServe(":8000", nil)
}

You can get it working like this:

$ go run test.go
 * Knight serving on :8000
 * Restarting with reloader
 * Detected change, reloading
 * Restarting with reloader
 * Detected change, reloading
 * Restarting with reloader

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Knight

type Knight struct {
	// contains filtered or unexported fields
}

func NewKnight

func NewKnight(root string) *Knight

func (Knight) ListenAndServe

func (knight Knight) ListenAndServe(addr string, handler http.Handler) error

Jump to

Keyboard shortcuts

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