This commit is contained in:
2025-12-16 21:23:28 +03:00
commit cb0b14799e
15 changed files with 1109 additions and 0 deletions

8
api/go.mod Normal file
View File

@@ -0,0 +1,8 @@
module archive.local
go 1.25.4
require (
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/mattn/go-sqlite3 v1.14.32 // indirect
)

8
api/go.sum Normal file
View File

@@ -0,0 +1,8 @@
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=

37
api/main.go Normal file
View File

@@ -0,0 +1,37 @@
package main
import (
"flag"
"fmt"
"log"
"net/http"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
)
var (
addr = flag.String("addr", ":5000", "http server address")
)
func main() {
flag.Parse()
db, err := sqlx.Connect("sqlite3", "./sqlite.db")
if err != nil {
log.Fatalf("failed to connect to db: %v\n", err)
}
defer db.Close()
if err := db.Ping(); err != nil {
log.Fatalf("failed to ping db: %v\n", err)
}
mux := http.NewServeMux()
fmt.Printf("starting http server at %s\n", *addr)
if err := http.ListenAndServe(*addr, mux); err != nil {
log.Fatalf("failed to start http server: %v\n", err)
}
}