Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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
iv
gitlab-workhorse
Commits
299ebeea
Commit
299ebeea
authored
Jul 26, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve auth request error handling
parent
4d3dd52c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
main.go
main.go
+11
-6
No files found.
main.go
View file @
299ebeea
...
...
@@ -46,7 +46,11 @@ func git_handler(w http.ResponseWriter, r *http.Request) {
for
_
,
g
:=
range
git_handlers
{
path_match
:=
g
.
regexp
.
FindStringSubmatch
(
r
.
URL
.
Path
)
if
r
.
Method
==
g
.
method
&&
path_match
!=
nil
{
auth_response
:=
do_auth_request
(
r
)
auth_response
,
err
:=
do_auth_request
(
r
)
if
err
!=
nil
{
fail_500
(
w
,
err
)
return
}
if
auth_response
.
StatusCode
!=
200
{
for
k
,
v
:=
range
auth_response
.
Header
{
w
.
Header
()[
k
]
=
v
...
...
@@ -55,8 +59,9 @@ func git_handler(w http.ResponseWriter, r *http.Request) {
io
.
Copy
(
w
,
auth_response
.
Body
)
return
}
if
_
,
err
:=
fmt
.
Fscan
(
auth_response
.
Body
,
user
);
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fscan
(
auth_response
.
Body
,
&
user
);
err
!=
nil
{
fail_500
(
w
,
err
)
return
}
g
.
handle_func
(
user
,
g
.
rpc
,
path
.
Join
(
repo_root
,
path_match
[
1
]),
w
,
r
)
return
...
...
@@ -66,21 +71,21 @@ func git_handler(w http.ResponseWriter, r *http.Request) {
w
.
WriteHeader
(
404
)
}
func
do_auth_request
(
r
*
http
.
Request
)
*
http
.
Response
{
func
do_auth_request
(
r
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
var
err
error
url
:=
fmt
.
Sprintf
(
"%s%s"
,
*
auth_backend
,
r
.
URL
.
RequestURI
())
auth_req
,
err
:=
http
.
NewRequest
(
r
.
Method
,
url
,
nil
)
if
err
!=
nil
{
return
&
http
.
Response
{
StatusCode
:
500
}
return
nil
,
err
}
for
k
,
v
:=
range
r
.
Header
{
auth_req
.
Header
[
k
]
=
v
}
result
,
err
:=
http_client
.
Do
(
auth_req
)
if
err
!=
nil
{
return
&
http
.
Response
{
StatusCode
:
500
}
return
nil
,
err
}
return
result
return
nil
,
err
}
func
handle_get_info_refs
(
user
string
,
_
string
,
path
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
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