sfcs/server/jsonDumper.go

20 lines
426 B
Go
Raw Normal View History

package server
import (
"encoding/json"
"fmt"
"net/http"
)
func (server *Server) jsonDumper(w http.ResponseWriter, r *http.Request) {
json, err := json.Marshal(server)
if err != nil {
fmt.Println("JSON Marshaling error:", err)
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("This is my Website"))
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(json)
}