2023-06-13 19:55:59 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"net/http/fcgi"
|
|
|
|
)
|
|
|
|
|
|
|
|
func hello(w http.ResponseWriter, r *http.Request) {
|
|
|
|
keys, ok := r.URL.Query()["name"]
|
|
|
|
|
|
|
|
if !ok || len(keys[0]) < 1 {
|
|
|
|
fmt.Fprintf(w, "Hello world!")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
key := keys[0]
|
2023-08-31 07:36:48 +00:00
|
|
|
fmt.Fprintf(w, "Hello "+key+"!")
|
2023-06-13 19:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
http.HandleFunc("/hello", hello)
|
|
|
|
|
2023-08-31 07:36:48 +00:00
|
|
|
l, err := net.Listen("tcp", "0.0.0.0:9000") //nolint:gosec // Ignore the gosec error since it's a hello server
|
2023-06-13 19:55:59 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2023-07-03 12:50:52 +00:00
|
|
|
if err := fcgi.Serve(l, nil); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2023-06-13 19:55:59 +00:00
|
|
|
}
|