mirror of
https://github.com/hanzozt/sdk-golang.git
synced 2026-10-30 14:46:37 +00:00
- Repo names: ziti-* → zt-* - Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt - Docker images: hanzozt/ziti-* → hanzozt/zt-* - C/Java/JS symbols: ziti_* → zt_* - File and directory names updated
29 lines
566 B
Go
29 lines
566 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
http.HandleFunc("/hello", hello)
|
|
http.HandleFunc("/add", add)
|
|
if err := http.ListenAndServe(":8090", nil); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func hello(w http.ResponseWriter, req *http.Request) {
|
|
host, _ := os.Hostname()
|
|
_, _ = fmt.Fprintf(w, "ztfied hello from %s", host)
|
|
}
|
|
|
|
func add(w http.ResponseWriter, req *http.Request) {
|
|
a, _ := strconv.Atoi(req.URL.Query().Get("a"))
|
|
b, _ := strconv.Atoi(req.URL.Query().Get("b"))
|
|
c := a + b
|
|
_, _ = fmt.Fprintf(w, "a+b=%d+%d=%d", a, b, c)
|
|
}
|