Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
haoqu.ma
/
gotty
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b18d35f2
authored
Aug 22, 2015
by
Iwasaki Yudai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show URLs on starting
1 parent
89232205
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletions
app/app.go
app/app.go
View file @
b18d35f
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"github.com/elazarl/go-bindata-assetfs"
"github.com/elazarl/go-bindata-assetfs"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
"github.com/kr/pty"
"github.com/kr/pty"
"net"
)
)
type
App
struct
{
type
App
struct
{
...
@@ -68,7 +69,17 @@ func (app *App) Run() error {
...
@@ -68,7 +69,17 @@ func (app *App) Run() error {
siteHandler
=
wrapLogger
(
siteHandler
)
siteHandler
=
wrapLogger
(
siteHandler
)
log
.
Printf
(
"Server is running at %s, command: %s"
,
endpoint
+
path
,
strings
.
Join
(
app
.
options
.
Command
,
" "
))
log
.
Printf
(
"Server is starting with command: %s"
,
strings
.
Join
(
app
.
options
.
Command
,
" "
),
)
if
app
.
options
.
Address
!=
""
{
log
.
Printf
(
"URL: %s"
,
"http://"
+
endpoint
+
path
)
}
else
{
for
_
,
address
:=
range
listAddresses
()
{
log
.
Printf
(
"URL: %s"
,
"http://"
+
address
+
":"
+
app
.
options
.
Port
+
path
)
}
}
if
err
:=
http
.
ListenAndServe
(
endpoint
,
siteHandler
);
err
!=
nil
{
if
err
:=
http
.
ListenAndServe
(
endpoint
,
siteHandler
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -153,3 +164,24 @@ func generateRandomString(length int) string {
...
@@ -153,3 +164,24 @@ func generateRandomString(length int) string {
}
}
return
string
(
n
)
return
string
(
n
)
}
}
func
listAddresses
()
(
addresses
[]
string
)
{
ifaces
,
_
:=
net
.
Interfaces
()
addresses
=
make
([]
string
,
0
,
len
(
ifaces
))
for
_
,
iface
:=
range
ifaces
{
ifAddrs
,
_
:=
iface
.
Addrs
()
for
_
,
ifAddr
:=
range
ifAddrs
{
switch
v
:=
ifAddr
.
(
type
)
{
case
*
net
.
IPNet
:
addresses
=
append
(
addresses
,
v
.
IP
.
String
())
case
*
net
.
IPAddr
:
addresses
=
append
(
addresses
,
v
.
IP
.
To16
()
.
String
())
addresses
=
append
(
addresses
,
v
.
IP
.
To4
()
.
String
())
}
}
}
return
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment