Files
crowsnest/cmd/frontend/main.go

42 lines
894 B
Go
Raw Normal View History

2024-12-20 01:15:56 +01:00
package main
import (
"fmt"
"net/http"
"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))
//a := &model.Article{}
2024-12-27 03:25:44 +01:00
2024-12-27 22:34:43 +01:00
fds, _ := data.NewFileDatastore("data.json")
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
}