mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2020-11-18 19:53:40 -08:00
28 lines
568 B
Go
28 lines
568 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/bmizerany/pat"
|
|
)
|
|
|
|
// hello world, the web server
|
|
func HelloServer(w http.ResponseWriter, req *http.Request) {
|
|
io.WriteString(w, "hello, "+req.URL.Query().Get(":name")+"!\n")
|
|
}
|
|
|
|
func main() {
|
|
m := pat.New()
|
|
m.Get("/hello/:name", http.HandlerFunc(HelloServer))
|
|
|
|
// Register this pat with the default serve mux so that other packages
|
|
// may also be exported. (i.e. /debug/pprof/*)
|
|
http.Handle("/", m)
|
|
err := http.ListenAndServe(":12345", nil)
|
|
if err != nil {
|
|
log.Fatal("ListenAndServe: ", err)
|
|
}
|
|
}
|