main.go 835 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. "strings"
  7. "time"
  8. )
  9. func main() {
  10. http.HandleFunc("/", slash) // Устанавливаем роутер
  11. http.HandleFunc("/ok", ok) // Устанавливаем роутер ok
  12. http.HandleFunc("/info", info) // Устанавливаем роутер info
  13. http.HandleFunc("/status", status) // Устанавливаем роутер info
  14. err := http.ListenAndServe("localhost:0808", nil) // устанавливаем порт веб-сервера
  15. if err != nil {
  16. log.Fatal("ListenAndServe: ", err)
  17. }
  18. }
  19. func slash (w http.ResponseWriter,r *http.Request) {
  20. fmt.Fprint(w,"it alive")
  21. }
  22. func ok (w http.ResponseWriter,r *http.Request) {
  23. w.WriteHeader(http.StatusOK)
  24. fmt.Fprint(w,"http status ok ")
  25. }
  26. func info (w http.ResponseWriter,r *http.Request) {
  27. fmt.Fprint(w,"LI Vladislave♂")
  28. }