|
1 | 1 | package app |
2 | 2 |
|
3 | | -import ( |
4 | | - "mjpclab.dev/ghfs/src/goVirtualHost" |
5 | | - "mjpclab.dev/ghfs/src/param" |
6 | | - "mjpclab.dev/ghfs/src/util" |
7 | | - "strconv" |
8 | | -) |
| 3 | +func (app *App) GetAccessibleUrls(includeLoopback bool) (allUrls [][]string) { |
| 4 | + allOrigins := app.vhostSvc.GetAccessibleURLs(includeLoopback) |
| 5 | + allUrls = make([][]string, len(allOrigins)) |
9 | 6 |
|
10 | | -func printAccessibleURLs(vhSvc *goVirtualHost.Service, params param.Params) { |
11 | | - vhostsUrls := vhSvc.GetAccessibleURLs(false) |
12 | | - file, teardown := util.GetTTYFile() |
13 | | - |
14 | | - for vhIndex := range vhostsUrls { |
15 | | - prefix := "" |
16 | | - if len(params[vhIndex].PrefixUrls) > 0 { |
17 | | - prefix = params[vhIndex].PrefixUrls[0] |
| 7 | + for vhIndex, vhOrigins := range allOrigins { |
| 8 | + vhPrefixes := app.params[vhIndex].PrefixUrls |
| 9 | + if len(vhPrefixes) == 0 { |
| 10 | + vhPrefixes = []string{""} |
18 | 11 | } |
19 | 12 |
|
20 | | - file.WriteString("Host " + strconv.Itoa(vhIndex) + " may be accessed by URLs:\n") |
21 | | - for urlIndex := range vhostsUrls[vhIndex] { |
22 | | - file.WriteString(" " + vhostsUrls[vhIndex][urlIndex] + prefix + "/\n") |
| 13 | + allUrls[vhIndex] = make([]string, 0, len(vhOrigins)*len(vhPrefixes)) |
| 14 | + |
| 15 | + for _, origin := range vhOrigins { |
| 16 | + for _, prefix := range vhPrefixes { |
| 17 | + allUrls[vhIndex] = append(allUrls[vhIndex], origin+prefix+"/") |
| 18 | + } |
23 | 19 | } |
24 | 20 | } |
25 | 21 |
|
26 | | - teardown() |
| 22 | + return |
27 | 23 | } |
0 commit comments