Skip to content

Commit 7a3e796

Browse files
committed
add port to static server port
1 parent bd6e871 commit 7a3e796

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

multiple-servers/cmd/static-server/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func main() {
1717
}
1818

1919
static.Run(static.Config{
20-
Dir: absPath,
20+
Dir: absPath,
21+
Port: 8080,
2122
})
2223
}

multiple-servers/static/static.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package static
22

33
import (
4+
"fmt"
45
"log"
56
"net/http"
67
"path/filepath"
78
)
89

910
type Config struct {
10-
Dir string
11+
Dir string
12+
Port int
1113
}
1214

1315
func Run(config Config) {
@@ -21,5 +23,5 @@ func Run(config Config) {
2123
http.ServeFile(w, r, path)
2224
})
2325

24-
log.Fatal(http.ListenAndServe(":8080", nil))
26+
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", config.Port), nil))
2527
}

0 commit comments

Comments
 (0)