Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "net/http"
- "strings"
- )
- func sayHello(w http.ResponseWriter, r *http.Request) {
- name := "World"
- url := strings.Trim(r.RequestURI, "/")
- if len(url) > 0 {
- name = strings.Split(url, "/")[0]
- name = strings.ToUpper(name[0:1]) + name[1:] // change first symbol to Uppercase
- }
- w.Write([]byte("Hello, " + name + "!"))
- }
- func main() {
- http.HandleFunc("/", sayHello)
- err := http.ListenAndServe(":80", nil)
- if err != nil {
- panic(err.Error())
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement