main.go 547 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "net/http"
  4. "log"
  5. "fmt"
  6. )
  7. func main() {
  8. http.HandleFunc("/api/greeting", greetingHandler)
  9. http.Handle("/", http.FileServer(http.Dir("resources")))
  10. log.Println("Listening on https://localhost:8443")
  11. err := http.ListenAndServeTLS(":8443", "certs/localhost.cert", "certs/localhost.key", nil)
  12. log.Fatal(err)
  13. }
  14. func greetingHandler(w http.ResponseWriter, r *http.Request) {
  15. w.Header().Set("Content-Type", "text/plain; charset=utf8")
  16. _, err := fmt.Fprint(w, "Hallo Quintor!")
  17. if err != nil {
  18. log.Println(err)
  19. }
  20. }