pogo/webserver.go
gmemstr e193e33678 Actual initial commit
Implements basic RSS generation and file watching, along with webserver to serve RSS file
2017-06-13 22:57:02 -07:00

25 lines
563 B
Go

package main
import (
"fmt"
"log"
"io/ioutil"
"net/http"
)
func rootHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/rss+xml")
w.WriteHeader(http.StatusOK)
data, err := ioutil.ReadFile("feed.rss")
if err != nil {
panic(err)
}
w.Header().Set("Content-Length", fmt.Sprint(len(data)))
fmt.Fprint(w, string(data))
}
func main() {
go watch()
http.HandleFunc("/", rootHandler)
log.Fatal(http.ListenAndServe(":8080", nil))
fmt.Println("watching folder")
}