main.go819 chars42 lines
In this code, a http.HandleFunc
is used to handle incoming requests on the root path (/
). The function first checks if the request method is POST
. If it is, the request body is read using the ioutil.ReadAll
method, and the resulting byte slice is converted to a string. This string then contains the HTML sent in the request body, which can be printed or further processed as necessary.
If the request method is not POST
, the function simply writes a response indicating that a POST
request with an HTML body is expected.
Finally, the server is started using http.ListenAndServe
on port 8080
.
gistlibby LogSnag