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
22707edc
Commit
22707edc
authored
Mar 28, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored fastcgi middleware to return errors
parent
7578298b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+11
-12
No files found.
middleware/fastcgi/fastcgi.go
View file @
22707edc
...
...
@@ -6,7 +6,6 @@ package fastcgi
import
(
"io"
"io/ioutil"
"log"
"net/http"
"path/filepath"
"strings"
...
...
@@ -27,8 +26,8 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
rules
=
append
(
rules
,
rule
)
}
return
func
(
next
http
.
HandlerFunc
)
http
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
return
func
(
next
middleware
.
HandlerFunc
)
middleware
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
servedFcgi
:=
false
for
_
,
rule
:=
range
rules
{
...
...
@@ -38,15 +37,13 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
// Get absolute file paths
absPath
,
err
:=
filepath
.
Abs
(
root
+
r
.
URL
.
Path
)
if
err
!=
nil
{
// TODO!
log
.
Fatal
(
err
)
return
http
.
StatusInternalServerError
,
err
}
// Get absolute file path
s
// Get absolute file path
to website root
absRootPath
,
err
:=
filepath
.
Abs
(
root
)
if
err
!=
nil
{
// TODO!
log
.
Fatal
(
err
)
return
http
.
StatusInternalServerError
,
err
}
// Separate remote IP and port
...
...
@@ -73,17 +70,17 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
fcgi
,
err
:=
Dial
(
"tcp"
,
rule
.
address
)
if
err
!=
nil
{
// TODO!
return
http
.
StatusBadGateway
,
err
}
resp
,
err
:=
fcgi
.
Get
(
env
)
if
err
!=
nil
&&
err
!=
io
.
EOF
{
// TODO!
return
http
.
StatusBadGateway
,
err
}
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
// TODO!
return
http
.
StatusBadGateway
,
err
}
for
key
,
vals
:=
range
resp
.
Header
{
...
...
@@ -100,8 +97,10 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
}
if
!
servedFcgi
{
next
(
w
,
r
)
return
next
(
w
,
r
)
}
return
0
,
nil
}
},
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