about summary refs log tree commit diff
path: root/server.go
blob: 69d528b2a2db22c396bd60fd5873b6fe84001fa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main

import (
	"flag"
	"fmt"
	"log"

	"net/http"

	"github.com/gorilla/mux"
)

var (
	categories []string
	port       int
)

func main() {
	initFlags()
	r := mux.NewRouter()

	r.HandleFunc("/", indexHandler)
	r.HandleFunc("/dumpall", dumpallHandler)
	r.HandleFunc("/{station}/{name}", getHandler)

	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), r))
}

func initFlags() {
	flag.IntVar(&port, "p", 8080, "the port the server should listen on")
	flag.Parse()
}