bingus-api: Initial commit

merge-requests/1/head
Ben Marsh 9 months ago
commit 39293d6d17

@ -0,0 +1,3 @@
module github.com/onefoggyscreen/bingus-api
go 1.18

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

@ -0,0 +1,52 @@
package main
import (
"embed"
"encoding/json"
"fmt"
"log"
"net/http"
)
//go:embed images/*
var content embed.FS
const Port = "9000"
const APIVersion = "1.0"
const shortForm = "2006-Jan-02"
type App struct {
Day string
ImgageURL string
}
func updateData(a *App) {
}
func return_json(w http.ResponseWriter, r *http.Request) {
jsonB := make(map[string]string)
jsonB["date"] = "Today's date!"
jsonB["picture"] = "dummy!"
jsonB["api-version"] = APIVersion
jsonF, error := json.Marshal(jsonB)
if error == nil {
w.WriteHeader(500)
w.Write([]byte("Error constructing json!"))
return
}
w.WriteHeader(200)
w.Header().Set("Content-Type", "application/json")
w.Write(jsonF)
return
}
func main() {
fmt.Println("Running Bingus API version "+APIVersion,
"\nReport any problems to your local Bingus chatper.",
"\nSpinning up server on PORT: "+Port)
//http.Handle("/", http.StripPrefix("/", http.FileServer(http.FS(content))))
http.HandleFunc("/", return_json)
log.Fatal(http.ListenAndServe(":"+Port, nil))
}
Loading…
Cancel
Save