pogo/webserver.go

38 lines
806 B
Go
Raw Normal View History

/* webserver.go
2017-09-21 20:10:16 +01:00
*
* This is the webserver handler for Pogo, and handles
2017-09-21 20:10:16 +01:00
* all incoming connections, including authentication.
2017-09-11 20:12:24 +01:00
*/
package main
import (
"fmt"
"log"
"net/http"
2017-12-04 00:26:09 +00:00
"os"
"github.com/gmemstr/pogo/router"
)
// Main function that defines routes
func main() {
2017-12-04 00:26:09 +00:00
// Check if this is the first time Pogo has been run
// with a lockfile
if _, err := os.Stat("run.lockfile"); os.IsNotExist(err) {
fmt.Println("This looks like your first time running Pogo,\ngive me a second to set myself up.")
Setup()
2017-12-04 00:26:09 +00:00
}
// Start the watch() function in generate_rss.go, which
2017-09-21 20:10:16 +01:00
// watches for file changes and regenerates the feed
2017-10-05 06:48:02 +01:00
go watch()
// Define routes
2017-10-03 12:08:27 +01:00
// We're live
r := router.Init()
fmt.Println("Your Pogo instance is live on port :3000")
2017-10-03 12:08:27 +01:00
log.Fatal(http.ListenAndServe(":3000", r))
}