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
affd4708
Commit
affd4708
authored
Jan 29, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved fastcgi middleware into its own package
parent
89783ac0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+15
-12
No files found.
middleware/fastcgi.go
→
middleware/fastcgi
/fastcgi
.go
View file @
affd4708
package
middleware
// FastCGI is middleware that acts as a FastCGI client. Requests
// that get forwarded to FastCGI stop the middleware execution
// chain. The most common use for this layer is to serve PHP
// websites with php-fpm.
package
fastcgi
import
(
import
(
"io"
"io"
...
@@ -8,21 +12,20 @@ import (
...
@@ -8,21 +12,20 @@ import (
"path/filepath"
"path/filepath"
"strings"
"strings"
"github.com/mholt/caddy/middleware"
"bitbucket.org/PinIdea/fcgi_client"
// TODO: Inline this dependency. It'll need some work.
"bitbucket.org/PinIdea/fcgi_client"
// TODO: Inline this dependency. It'll need some work.
)
)
// FastCGI is middleware that acts as a FastCGI client. Requests
// New generates a new FastCGI middleware.
// that get forwarded to FastCGI stop the middleware execution
func
New
(
c
middleware
.
Controller
)
(
middleware
.
Middleware
,
error
)
{
// chain. The most common use for this layer is to serve PHP
root
:=
c
.
Root
()
// websites with php-fpm.
func
FastCGI
(
p
parser
)
Middleware
{
root
:=
p
.
Root
()
var
rules
[]
fastCgi
var
rules
[]
fastCgi
for
p
.
Next
()
{
for
c
.
Next
()
{
rule
:=
fastCgi
{}
rule
:=
fastCgi
{}
if
!
p
.
Args
(
&
rule
.
path
,
&
rule
.
address
)
{
if
!
c
.
Args
(
&
rule
.
path
,
&
rule
.
address
)
{
return
p
.
ArgErr
()
return
nil
,
c
.
ArgErr
()
}
}
rules
=
append
(
rules
,
rule
)
rules
=
append
(
rules
,
rule
)
}
}
...
@@ -32,7 +35,7 @@ func FastCGI(p parser) Middleware {
...
@@ -32,7 +35,7 @@ func FastCGI(p parser) Middleware {
servedFcgi
:=
false
servedFcgi
:=
false
for
_
,
rule
:=
range
rules
{
for
_
,
rule
:=
range
rules
{
if
Path
(
r
.
URL
.
Path
)
.
Matches
(
rule
.
path
)
{
if
middleware
.
Path
(
r
.
URL
.
Path
)
.
Matches
(
rule
.
path
)
{
servedFcgi
=
true
servedFcgi
=
true
// Get absolute file paths
// Get absolute file paths
...
@@ -102,7 +105,7 @@ func FastCGI(p parser) Middleware {
...
@@ -102,7 +105,7 @@ func FastCGI(p parser) Middleware {
next
(
w
,
r
)
next
(
w
,
r
)
}
}
}
}
}
}
,
nil
}
}
type
fastCgi
struct
{
type
fastCgi
struct
{
...
...
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