2016-09-14 03:45:49 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/prologic/go-gopher"
|
|
|
|
)
|
|
|
|
|
|
|
|
func index(w gopher.ResponseWriter, r *gopher.Request) {
|
|
|
|
w.WriteItem(
|
|
|
|
gopher.Item{
|
2016-09-14 06:23:46 +00:00
|
|
|
Type: gopher.DIRECTORY,
|
2016-09-14 03:45:49 +00:00
|
|
|
Selector: "/hello",
|
|
|
|
Description: "hello",
|
|
|
|
},
|
|
|
|
)
|
2016-09-14 06:23:46 +00:00
|
|
|
w.WriteItem(
|
|
|
|
gopher.Item{
|
|
|
|
Type: gopher.FILE,
|
|
|
|
Selector: "/foo",
|
|
|
|
Description: "foo",
|
|
|
|
},
|
|
|
|
)
|
2016-09-23 11:34:12 +00:00
|
|
|
w.WriteItem(
|
|
|
|
gopher.Item{
|
|
|
|
Type: gopher.DIRECTORY,
|
|
|
|
Selector: "/",
|
|
|
|
Description: "Floodgap",
|
|
|
|
Host: "gopher.floodgap.com",
|
|
|
|
Port: 70,
|
|
|
|
},
|
|
|
|
)
|
2016-09-14 03:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func hello(w gopher.ResponseWriter, r *gopher.Request) {
|
|
|
|
w.WriteInfo("Hello World!")
|
|
|
|
}
|
|
|
|
|
2016-09-14 06:23:46 +00:00
|
|
|
func foo(w gopher.ResponseWriter, r *gopher.Request) {
|
|
|
|
w.Write([]byte("Foo!"))
|
|
|
|
}
|
|
|
|
|
2016-09-14 03:45:49 +00:00
|
|
|
func main() {
|
|
|
|
gopher.HandleFunc("/", index)
|
2016-09-14 06:23:46 +00:00
|
|
|
gopher.HandleFunc("/foo", foo)
|
2016-09-14 03:45:49 +00:00
|
|
|
gopher.HandleFunc("/hello", hello)
|
|
|
|
log.Fatal(gopher.ListenAndServe("localhost:70", nil))
|
|
|
|
}
|