40 lines
872 B
Go
40 lines
872 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"crowsnest-frontend/internal/model"
|
|
"crowsnest-frontend/internal/data"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
|
|
func PrintAllKeys(ds data.IDatastore) {
|
|
m, err := ds.GetAllKeys()
|
|
fmt.Println(m, err)
|
|
}
|
|
|
|
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{}
|
|
|
|
fds, _ := data.NewFileDatastore("data.json")
|
|
fmt.Println(fds.jetAll())
|
|
repo := data.NewDefaultRepository[*model.Article](fds, "article")
|
|
fmt.Println(repo.Create(a))
|
|
|
|
//http.ListenAndServe(":8090", nil)
|
|
}
|