commit e17249cbe61a4d85a2b46336c1acf2f4ccba4fe2 Author: Eliot Whalan Date: Fri Jun 10 23:56:42 2016 +1000 Setup simple webserver and get basic paste saving working diff --git a/main.go b/main.go new file mode 100644 index 0000000..88317c6 --- /dev/null +++ b/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "io/ioutil" + "net/http" +) + +func check(e error) { + if e != nil { + panic(e) + } +} + +func pasteHandler(w http.ResponseWriter, req *http.Request) { + buf, _ := ioutil.ReadAll(req.Body) + paste := buf[89 : len(buf)-46] + err := ioutil.WriteFile("/tmp/dat1", paste, 0644) + check(err) +} + +func main() { + http.HandleFunc("/", pasteHandler) + http.ListenAndServe(":8080", nil) + +}