43 lines
689 B
Go
43 lines
689 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type rq struct {
|
|
w http.ResponseWriter
|
|
r *http.Request
|
|
}
|
|
|
|
type conf struct {
|
|
Database string
|
|
Listenport string
|
|
Userlist string
|
|
}
|
|
|
|
var users userList
|
|
var config conf
|
|
|
|
func main() {
|
|
|
|
confPath := os.Args[1]
|
|
|
|
rawconf, err := os.ReadFile(confPath)
|
|
if err != nil {
|
|
fmt.Println("Could not read config file")
|
|
os.Exit(1)
|
|
}
|
|
|
|
yaml.Unmarshal(rawconf,&config)
|
|
|
|
users = make(userList)
|
|
users.loadFromFile(config.Userlist)
|
|
http.HandleFunc("/logs/", logsHandler)
|
|
if err := http.ListenAndServe(":"+config.Listenport, nil); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|