Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
caddy
Commits
d00bb87f
Commit
d00bb87f
authored
Apr 28, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-port flag to override default port
Default port used if none is specified in config
parent
0f332bd9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
11 deletions
+15
-11
config/config.go
config/config.go
+9
-6
config/parser_test.go
config/parser_test.go
+4
-4
config/parsing.go
config/parsing.go
+1
-1
main.go
main.go
+1
-0
No files found.
config/config.go
View file @
d00bb87f
...
...
@@ -11,14 +11,17 @@ import (
)
const
(
d
efaultHost
=
"localhost"
d
efaultPort
=
"2015"
d
efaultRoot
=
"."
D
efaultHost
=
"localhost"
D
efaultPort
=
"2015"
D
efaultRoot
=
"."
// The default configuration file to load if none is specified
DefaultConfigFile
=
"Caddyfile"
)
// Port is configurable via command line flag
var
Port
=
DefaultPort
// config represents a server configuration. It
// is populated by parsing a config file (via the
// Load function).
...
...
@@ -113,9 +116,9 @@ func IsNotFound(err error) bool {
func
Default
()
[]
Config
{
cfg
:=
[]
Config
{
Config
{
Root
:
d
efaultRoot
,
Host
:
d
efaultHost
,
Port
:
default
Port
,
Root
:
D
efaultRoot
,
Host
:
D
efaultHost
,
Port
:
Port
,
},
}
return
cfg
...
...
config/parser_test.go
View file @
d00bb87f
...
...
@@ -170,8 +170,8 @@ func TestParserBasicWithMultipleHostsPerBlock(t *testing.T) {
if
confs
[
0
]
.
Host
!=
"host1.com"
{
t
.
Errorf
(
"Expected host of first conf to be 'host1.com', got '%s'"
,
confs
[
0
]
.
Host
)
}
if
confs
[
0
]
.
Port
!=
d
efaultPort
{
t
.
Errorf
(
"Expected port of first conf to be '%s', got '%s'"
,
d
efaultPort
,
confs
[
0
]
.
Port
)
if
confs
[
0
]
.
Port
!=
D
efaultPort
{
t
.
Errorf
(
"Expected port of first conf to be '%s', got '%s'"
,
D
efaultPort
,
confs
[
0
]
.
Port
)
}
if
confs
[
0
]
.
Root
!=
"/public_html"
{
t
.
Errorf
(
"Expected root of first conf to be '/public_html', got '%s'"
,
confs
[
0
]
.
Root
)
...
...
@@ -255,8 +255,8 @@ func TestParserBasicWithAlternateAddressStyles(t *testing.T) {
if
confs
[
4
]
.
Host
!=
"host"
{
t
.
Errorf
(
"Expected conf[4] Host='host', got '%#v'"
,
confs
[
4
])
}
if
confs
[
4
]
.
Port
!=
d
efaultPort
{
t
.
Errorf
(
"Expected conf[4] Port='%s', got '%#v'"
,
d
efaultPort
,
confs
[
4
]
.
Port
)
if
confs
[
4
]
.
Port
!=
D
efaultPort
{
t
.
Errorf
(
"Expected conf[4] Port='%s', got '%#v'"
,
D
efaultPort
,
confs
[
4
]
.
Port
)
}
}
...
...
config/parsing.go
View file @
d00bb87f
...
...
@@ -47,7 +47,7 @@ func (p *parser) addresses() error {
schemePort
=
"http"
str
=
str
[
7
:
]
}
else
if
!
strings
.
Contains
(
str
,
":"
)
{
str
+=
":"
+
default
Port
str
+=
":"
+
Port
}
host
,
port
,
err
=
net
.
SplitHostPort
(
str
)
...
...
main.go
View file @
d00bb87f
...
...
@@ -27,6 +27,7 @@ func init() {
flag
.
BoolVar
(
&
http2
,
"http2"
,
true
,
"enable HTTP/2 support"
)
// TODO: temporary flag until http2 merged into std lib
flag
.
BoolVar
(
&
quiet
,
"quiet"
,
false
,
"quiet mode (no initialization output)"
)
flag
.
StringVar
(
&
cpu
,
"cpu"
,
"100%"
,
"CPU cap"
)
flag
.
StringVar
(
&
config
.
Port
,
"port"
,
config
.
DefaultPort
,
"Default port"
)
flag
.
Parse
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment