vanity-tester-backend-go/cmd/vanity-tester-backend/main.go

44 lines
804 B
Go
Raw Normal View History

2024-12-27 14:04:18 -03:00
package main
import (
"context"
"database/sql"
"log"
"net/http"
_ "github.com/mattn/go-sqlite3"
)
var client *http.Client
var rctx = context.Background()
var config = loadConfig("./config.json")
func main() {
// redisDb := redis.NewClient(&redis.Options{
// Addr: config.Redis.Addr,
// DB: config.Redis.DB,
// })
db, err := sql.Open("sqlite3", "./database.db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
createDb(db)
mux := http.NewServeMux()
mux.HandleFunc("/", root)
// mux.HandleFunc("/health", health())
// mux.HandleFunc("/stats", stats())
srv := &http.Server{
Handler: mux,
Addr: config.HTTPServer.Addr + ":" + config.HTTPServer.Port,
}
srv.ListenAndServe()
log.Printf("Server running at %s:%s", config.HTTPServer.Addr, config.HTTPServer.Port)
}