okospaceapi/cmd/server.go
Aaron Fischer 626b3827d2
All checks were successful
/ docker-image (push) Successful in 4m33s
/ deployment (push) Successful in 0s
add forgejo
2024-01-23 20:31:35 +01:00

90 lines
2.2 KiB
Go

package main
import (
"git.okoyono.de/oko-intern/okospaceapi/pkg/spaceapi"
"net/http"
)
//go:generate ../generate-spaceapi-types.sh
func main() {
definition := spaceapi.Root{
// TODO: Fill up with stuff
ApiCompatibility: []string{"14"},
Space: "økoyono",
Url: "https://okoyono.de/",
Contact: &spaceapi.Contact{
Email: "oko@datenhalter.de", // TODO: Better email
Mastodon: "@f@social.okoyono.de", // TODO: Replace with real handle
Matrix: "#public:matrix.okoyono.de",
},
Location: &spaceapi.Location{
Lat: 27.987850, // Latitude and Longitude of Mount Everest :)
Lon: 86.925026,
Timezone: "Europe/Berlin",
},
Logo: "https://okoyono.de/images/ant.svg",
Links: []*spaceapi.LinksItems{
{
Description: "Website",
Name: "website",
Url: "https://okoyono.de",
},
{
Description: "Mastodon (Social Media)",
Name: "mastodon",
Url: "https://social.okoyono.de",
},
{
Description: "Forgejo (Git)",
Name: "forgejo",
Url: "https://git.okoyono.de",
},
{
Description: "SearXNG (Search)",
Name: "searxng",
Url: "https://search.okoyono.de",
},
},
Projects: []string{
"https://buchdesmonats.okoyono.de/",
"https://comicdesmonats.okoyono.de/",
"https://git.okoyono.de/okoyono/weatherstation",
},
Sensors: &spaceapi.Sensors{
TotalMemberCount: []*spaceapi.TotalMemberCountItems{
{
Description: "We are a small group of people from south Germany, meeting remote on a regular basis.",
Location: "Remote",
Value: 6,
},
},
//Temperature: []*spaceapi.TemperatureItems{
// {
// Location: "@f",
// Name: "weatherstatiøn",
// Description: "Weatherstatiøn located at @f.",
// Value: sensors.TemperatureF(),
// },
//},
},
}
json, err := definition.MarshalJSON()
if err != nil {
panic(err)
}
err = http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, err := w.Write(json)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}))
if err != nil {
panic(err)
}
}