okospaceapi/pkg/api/server.go

18 lines
371 B
Go
Raw Normal View History

package api
import "net/http"
func StartServer() {
err := http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, err := w.Write(BuildDefinition())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}))
if err != nil {
panic(err)
}
}