Formatting, long options
This commit is contained in:
parent
81bb79e8de
commit
1807f374ca
|
@ -2,30 +2,30 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"golang.org/x/net/webdav"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/net/webdav"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
webdav.Handler
|
webdav.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler)ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET", "HEAD":
|
case "GET", "HEAD":
|
||||||
if strings.HasSuffix(r.URL.Path, "/") {
|
if strings.HasSuffix(r.URL.Path, "/") {
|
||||||
r.URL.Path += "index.html"
|
r.URL.Path += "index.html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h.Handler.ServeHTTP(w, r)
|
h.Handler.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
address := flag.String("a", ":8080", "Address to listen to")
|
address := flag.String("listen", ":8080", "Address to listen to")
|
||||||
directory := flag.String("d", ".", "Directory to serve")
|
directory := flag.String("root", ".", "Directory to serve")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
handler := &Handler{}
|
handler := &Handler{}
|
||||||
|
|
Loading…
Reference in New Issue