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
nexedi
caddy
Commits
ed108634
Commit
ed108634
authored
Sep 08, 2015
by
Benoit Benedetti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Configuration as command line arg #222
parent
4e1717db
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
main.go
main.go
+7
-1
No files found.
main.go
View file @
ed108634
...
@@ -124,7 +124,7 @@ func isLocalhost(s string) bool {
...
@@ -124,7 +124,7 @@ func isLocalhost(s string) bool {
// loadConfigs loads configuration from a file or stdin (piped).
// loadConfigs loads configuration from a file or stdin (piped).
// The configurations are grouped by bind address.
// The configurations are grouped by bind address.
// Configuration is obtained from one of three sources, tried
// Configuration is obtained from one of three sources, tried
// in this order: 1. -conf flag, 2. stdin, 3. Caddyfile.
// in this order: 1. -conf flag, 2. stdin,
4. command line argument
3. Caddyfile.
// If none of those are available, a default configuration is
// If none of those are available, a default configuration is
// loaded.
// loaded.
func
loadConfigs
()
(
config
.
Group
,
error
)
{
func
loadConfigs
()
(
config
.
Group
,
error
)
{
...
@@ -155,6 +155,12 @@ func loadConfigs() (config.Group, error) {
...
@@ -155,6 +155,12 @@ func loadConfigs() (config.Group, error) {
}
}
}
}
// Command line Arg
if
flag
.
NArg
()
>
0
{
confBody
:=
":"
+
config
.
DefaultPort
+
"
\n
"
+
strings
.
Join
(
flag
.
Args
(),
"
\n
"
)
return
config
.
Load
(
"args"
,
bytes
.
NewBufferString
(
confBody
))
}
// Caddyfile
// Caddyfile
file
,
err
:=
os
.
Open
(
config
.
DefaultConfigFile
)
file
,
err
:=
os
.
Open
(
config
.
DefaultConfigFile
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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