This commit is contained in:
20
main.go
Normal file
20
main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Server struct{}
|
||||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(`{"message": "hello world"}`))
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := &Server{}
|
||||
http.Handle("/", s)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
20
main_test.go
Normal file
20
main_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Server struct{}
|
||||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(`{"message": "hello world"}`))
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := &Server{}
|
||||
http.Handle("/", s)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
Reference in New Issue
Block a user