2024-12-20 01:15:56 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
2024-12-29 00:56:47 +01:00
|
|
|
"crowsnest/internal/model"
|
|
|
|
|
"crowsnest/internal/data"
|
2024-12-20 01:15:56 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func test(w http.ResponseWriter, req *http.Request) {
|
|
|
|
|
for name, headers := range req.Header {
|
|
|
|
|
for _, h := range headers {
|
|
|
|
|
fmt.Fprintf(w, "%v: %v\n", name, h)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-27 22:34:43 +01:00
|
|
|
func PrintAllKeys(ds data.IDatastore) {
|
|
|
|
|
m, err := ds.GetAllKeys()
|
|
|
|
|
fmt.Println(m, err)
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-20 01:15:56 +01:00
|
|
|
func main() {
|
|
|
|
|
http.HandleFunc("/test", test)
|
|
|
|
|
|
|
|
|
|
// Serve files from the "static" directory
|
|
|
|
|
fs := http.FileServer(http.Dir("./static"))
|
|
|
|
|
http.Handle("/", http.StripPrefix("/", fs))
|
|
|
|
|
|
|
|
|
|
|
2024-12-29 00:56:47 +01:00
|
|
|
//a := &model.Article{}
|
2024-12-27 03:25:44 +01:00
|
|
|
|
2024-12-27 22:34:43 +01:00
|
|
|
fds, _ := data.NewFileDatastore("data.json")
|
2024-12-29 00:56:47 +01:00
|
|
|
fmt.Println(fds.GetAll())
|
|
|
|
|
|
|
|
|
|
repo, _ := data.NewDefaultRepository[*model.Article](fds, "article")
|
|
|
|
|
articles, _ := repo.GetAll()
|
|
|
|
|
fmt.Println(articles[0])
|
2024-12-27 03:25:44 +01:00
|
|
|
|
|
|
|
|
//http.ListenAndServe(":8090", nil)
|
2024-12-20 01:15:56 +01:00
|
|
|
}
|