Initial commit
This commit is contained in:
15
24 - HTTP Servers/httpserver/json.go
Normal file
15
24 - HTTP Servers/httpserver/json.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func HandleJsonRequest(writer http.ResponseWriter, request *http.Request) {
|
||||
writer.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(writer).Encode(Products)
|
||||
}
|
||||
|
||||
func init() {
|
||||
http.HandleFunc("/json", HandleJsonRequest)
|
||||
}
|
||||
Reference in New Issue
Block a user