Skip to content

Commit 9a5a02a

Browse files
maysunfaisalelsony
authored andcommitted
Update welcome msg
Signed-off-by: Maysun J Faisal <[email protected]>
1 parent 97338fd commit 9a5a02a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package main
22

33
import (
4+
"flag"
45
"fmt"
56
"net/http"
6-
"flag"
77
)
8+
89
var port = flag.Int("p", 8080, "server port")
910

1011
func main() {
@@ -14,5 +15,10 @@ func main() {
1415
}
1516

1617
func HelloServer(w http.ResponseWriter, r *http.Request) {
17-
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
18+
path := r.URL.Path[1:]
19+
if path != "" {
20+
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
21+
} else {
22+
fmt.Fprint(w, "Hello World!")
23+
}
1824
}

0 commit comments

Comments
 (0)