2017-07-23 09:20:22 +01:00
|
|
|
/* webserver.go
|
2017-09-21 20:10:16 +01:00
|
|
|
*
|
2017-09-11 19:36:40 +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
|
|
|
*/
|
2017-07-23 09:20:22 +01:00
|
|
|
|
2017-06-14 06:57:02 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-06-18 21:57:43 +01:00
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
2017-12-04 00:26:09 +00:00
|
|
|
"os"
|
2017-06-15 17:21:22 +01:00
|
|
|
|
2017-10-05 20:27:55 +01:00
|
|
|
"github.com/gmemstr/pogo/router"
|
2017-06-14 06:57:02 +01:00
|
|
|
)
|
2017-06-18 21:57:43 +01:00
|
|
|
|
2017-07-23 09:20:22 +01:00
|
|
|
// Main function that defines routes
|
2017-06-14 06:57:02 +01:00
|
|
|
func main() {
|
2017-12-05 01:39:33 +00:00
|
|
|
|
2017-12-04 00:26:09 +00:00
|
|
|
// Check if this is the first time Pogo has been run
|
|
|
|
// with a lockfile
|
2022-03-19 13:33:32 +00:00
|
|
|
if _, err := os.Stat("assets/config/config.json"); os.IsNotExist(err) {
|
2017-12-19 17:07:06 +00:00
|
|
|
fmt.Println("This looks like your first time running Pogo, give me a second to set myself up.")
|
2017-12-04 03:30:38 +00:00
|
|
|
Setup()
|
2017-12-04 00:26:09 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:20:22 +01: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()
|
2017-07-23 09:20:22 +01:00
|
|
|
|
|
|
|
// Define routes
|
2017-10-03 12:08:27 +01:00
|
|
|
// We're live
|
|
|
|
r := router.Init()
|
2017-11-21 05:47:29 +00:00
|
|
|
fmt.Println("Your Pogo instance is live on port :3000")
|
2017-10-03 12:08:27 +01:00
|
|
|
log.Fatal(http.ListenAndServe(":3000", r))
|
2017-06-18 21:57:43 +01:00
|
|
|
}
|