// NGnius 2020-01-30 package main // leadercraft-server import ( "fmt" "net/http" ) const ( // Version the current version Version = "0.1" // Name the program name Name = "leadercraft-s" ) var ( server *http.Server handler http.Handler port string root string boards map[string]Board ) func init() { initArgs() serverMux := http.NewServeMux() serverMux.HandleFunc("/load", boardHandler) handler = serverMux boards = make(map[string]Board) // test data boards["test1"] = Board{ ID: 1, Entries: []Entry{ Entry{ID: 1, Rank: 1, Score: 1000, PlayerName: "NGnius", PlayerURL: "/player/1"}, Entry{ID: 2, Rank: 2, Score: 900, PlayerName: "Also NGnius", PlayerURL: "/player/2"}, Entry{ID: 4, Rank: 3, Score: 400, PlayerName: ".xX||eDgY TeeNaGeR||Xx.", PlayerURL: "/player/3"}, Entry{ID: 3, Rank: 4, Score: 350, PlayerName: "New username who dis?", PlayerURL: "/player/4"}, Entry{ID: 7, Rank: 5, Score: 350, PlayerName: "Extremely Ridiculously Long Name Please don't break things", PlayerURL: "/player/5"}, Entry{ID: 5, Rank: 6, Score: 250, PlayerName: "P|P3 |o|z", PlayerURL: "/player/3333"}, Entry{ID: 6, Rank: 7, Score: 200, PlayerName: "Simon", PlayerURL: "/player/456"}, Entry{ID: 24, Rank: 8, Score: 175, PlayerName: "Zettagram.com", PlayerURL: "/player/32"}, Entry{ID: 42, Rank: 9, Score: 150, PlayerName: "The Doctor", PlayerURL: "/player/9283"}, Entry{ID: 43, Rank: 10, Score: 140, PlayerName: "Marvin the Paranoid Android", PlayerURL: "/player/6"}, Entry{ID: 8, Rank: 11, Score: 100, PlayerName: "IDK HOW", PlayerURL: "/player/666"}, }, } } func main() { parseArgs() server = &http.Server{ Addr: ":" + port, Handler: handler, } fmt.Println("Starting on " + server.Addr) fmt.Println(server.ListenAndServe()) }