mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-07-21 07:30:44 +02:00
initial import
This commit is contained in:
4
microservices/formrequest/Form-request.http
Normal file
4
microservices/formrequest/Form-request.http
Normal file
@ -0,0 +1,4 @@
|
||||
POST http://localhost:8080/ HTTP/1.1
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
name=Peter
|
3
microservices/formrequest/go.mod
Normal file
3
microservices/formrequest/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module golang.source-fellows.com/samples/formrequest
|
||||
|
||||
go 1.13
|
18
microservices/formrequest/main.go
Normal file
18
microservices/formrequest/main.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
||||
func handleForm(rw http.ResponseWriter, rq *http.Request) {
|
||||
err := rq.ParseForm()
|
||||
if err != nil {
|
||||
rw.WriteHeader(http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
name := rq.Form.Get("name")
|
||||
rw.Write([]byte("Hello " + name))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handleForm)
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
Reference in New Issue
Block a user