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
634b8b70
Commit
634b8b70
authored
Feb 07, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slight refactoring/renaming
parent
0e43271c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
config/controller.go
config/controller.go
+4
-2
config/dispenser.go
config/dispenser.go
+5
-5
config/middleware.go
config/middleware.go
+3
-3
config/parser.go
config/parser.go
+1
-1
No files found.
config/controller.go
View file @
634b8b70
...
...
@@ -6,15 +6,17 @@ package config
// the middleware.Controller interface.
type
controller
struct
{
dispenser
parser
*
parser
}
// newController returns a new controller.
func
newController
(
p
*
parser
)
*
controller
{
return
&
controller
{
dispenser
:
dispenser
{
cursor
:
-
1
,
parser
:
p
,
cursor
:
-
1
,
filename
:
p
.
filename
,
},
parser
:
p
,
}
}
...
...
config/dispenser.go
View file @
634b8b70
...
...
@@ -10,10 +10,10 @@ import (
// their instance. It basically dispenses tokens but can
// do so in a structured manner.
type
dispenser
struct
{
parser
*
parser
cursor
int
nesting
int
tokens
[]
token
filename
string
cursor
int
nesting
int
tokens
[]
token
}
// Next loads the next token. Returns true if a token
...
...
@@ -124,7 +124,7 @@ func (d *dispenser) ArgErr() error {
// the error in the dispenser after the middleware preparator
// is finished.
func
(
d
*
dispenser
)
Err
(
msg
string
)
error
{
msg
=
fmt
.
Sprintf
(
"%s:%d - Parse error: %s"
,
d
.
parser
.
filename
,
d
.
tokens
[
d
.
cursor
]
.
line
,
msg
)
msg
=
fmt
.
Sprintf
(
"%s:%d - Parse error: %s"
,
d
.
filename
,
d
.
tokens
[
d
.
cursor
]
.
line
,
msg
)
return
errors
.
New
(
msg
)
}
...
...
config/middleware.go
View file @
634b8b70
...
...
@@ -14,7 +14,7 @@ import (
// This init function registers middleware. Register middleware
// in the order they should be executed during a request.
// Middleware execute in
an order like this
: A-B-C-*-C-B-A
// Middleware execute in
this order
: A-B-C-*-C-B-A
func
init
()
{
register
(
"gzip"
,
gzip
.
New
)
register
(
"header"
,
headers
.
New
)
...
...
@@ -32,7 +32,7 @@ var (
// are bound.
registry
=
struct
{
directiveMap
map
[
string
]
middleware
.
Generator
order
[]
string
order
ed
[]
string
}{
directiveMap
:
make
(
map
[
string
]
middleware
.
Generator
),
}
...
...
@@ -43,7 +43,7 @@ var (
// executed in the order they are registered.
func
register
(
directive
string
,
generator
middleware
.
Generator
)
{
registry
.
directiveMap
[
directive
]
=
generator
registry
.
order
=
append
(
registry
.
order
,
directive
)
registry
.
order
ed
=
append
(
registry
.
ordered
,
directive
)
}
// middlewareRegistered returns whether or not a directive is registered.
...
...
config/parser.go
View file @
634b8b70
...
...
@@ -106,7 +106,7 @@ func (p *parser) parseOne() error {
// This function should be called only after p has filled out
// p.other and that the entire server block has been consumed.
func
(
p
*
parser
)
unwrap
()
error
{
for
directive
:=
range
registry
.
directiveMap
{
for
_
,
directive
:=
range
registry
.
ordered
{
if
disp
,
ok
:=
p
.
other
[
directive
];
ok
{
if
generator
,
ok
:=
registry
.
directiveMap
[
directive
];
ok
{
mid
,
err
:=
generator
(
disp
)
...
...
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