sbsqlitessgcms/main.go

39 lines
567 B
Go
Raw Permalink Normal View History

2022-11-19 02:19:28 +00:00
package main
import (
"errors"
"log"
"net/http"
"crawshaw.io/sqlite/sqlitex"
)
const addr = ":31337"
const dbPath = "./sbsqlitessgcms.db"
const baseURL = "http://localhost:31337"
var dbPool *sqlitex.Pool
func main() {
err := run()
if err != nil {
log.Fatal(err)
}
}
func run() error {
store, err := NewStore(dbPath)
if err != nil {
return err
}
defer store.Close()
log.Println("Listening on", addr)
err = http.ListenAndServe(addr, NewHandler(store, baseURL))
if errors.Is(err, http.ErrServerClosed) {
return nil
} else {
return err
}
}