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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
fb1df36e
Commit
fb1df36e
authored
Jan 08, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More http.Handler, less http.HandlerFunc
parent
14d70b3b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
16 deletions
+16
-16
authorization_test.go
authorization_test.go
+1
-1
internal/api/api.go
internal/api/api.go
+3
-3
internal/git/git-http.go
internal/git/git-http.go
+1
-1
internal/lfs/lfs.go
internal/lfs/lfs.go
+2
-2
internal/upload/uploads.go
internal/upload/uploads.go
+3
-3
internal/upstream/handlers.go
internal/upstream/handlers.go
+3
-3
internal/upstream/handlers_test.go
internal/upstream/handlers_test.go
+3
-3
No files found.
authorization_test.go
View file @
fb1df36e
...
...
@@ -28,7 +28,7 @@ func runPreAuthorizeHandler(t *testing.T, suffix string, url *regexp.Regexp, api
a
:=
&
api
.
API
{
URL
:
helper
.
URLMustParse
(
ts
.
URL
),
Version
:
"123"
}
response
:=
httptest
.
NewRecorder
()
a
.
PreAuthorizeHandler
(
okHandler
,
suffix
)(
response
,
httpRequest
)
a
.
PreAuthorizeHandler
(
okHandler
,
suffix
)
.
ServeHTTP
(
response
,
httpRequest
)
helper
.
AssertResponseCode
(
t
,
response
,
expectedCode
)
return
response
}
...
...
internal/api/api.go
View file @
fb1df36e
...
...
@@ -105,8 +105,8 @@ func (api *API) newRequest(r *http.Request, body io.Reader, suffix string) (*htt
return
authReq
,
nil
}
func
(
api
*
API
)
PreAuthorizeHandler
(
h
HandleFunc
,
suffix
string
)
http
.
Handler
Func
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
(
api
*
API
)
PreAuthorizeHandler
(
h
HandleFunc
,
suffix
string
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
authReq
,
err
:=
api
.
newRequest
(
r
,
nil
,
suffix
)
if
err
!=
nil
{
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"preAuthorizeHandler: newUpstreamRequest: %v"
,
err
))
...
...
@@ -160,5 +160,5 @@ func (api *API) PreAuthorizeHandler(h HandleFunc, suffix string) http.HandlerFun
}
h
(
w
,
r
,
a
)
}
}
)
}
internal/git/git-http.go
View file @
fb1df36e
...
...
@@ -36,7 +36,7 @@ func looksLikeRepo(p string) bool {
return
true
}
func
repoPreAuthorizeHandler
(
myAPI
*
api
.
API
,
handleFunc
api
.
HandleFunc
)
http
.
Handler
Func
{
func
repoPreAuthorizeHandler
(
myAPI
*
api
.
API
,
handleFunc
api
.
HandleFunc
)
http
.
Handler
{
return
myAPI
.
PreAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
api
.
Response
)
{
if
a
.
RepoPath
==
""
{
helper
.
Fail500
(
w
,
errors
.
New
(
"repoPreAuthorizeHandler: RepoPath empty"
))
...
...
internal/lfs/lfs.go
View file @
fb1df36e
...
...
@@ -20,11 +20,11 @@ import (
"path/filepath"
)
func
PutStore
(
a
*
api
.
API
,
p
*
proxy
.
Proxy
)
http
.
Handler
Func
{
func
PutStore
(
a
*
api
.
API
,
p
*
proxy
.
Proxy
)
http
.
Handler
{
return
lfsAuthorizeHandler
(
a
,
handleStoreLfsObject
(
p
))
}
func
lfsAuthorizeHandler
(
myAPI
*
api
.
API
,
handleFunc
api
.
HandleFunc
)
http
.
Handler
Func
{
func
lfsAuthorizeHandler
(
myAPI
*
api
.
API
,
handleFunc
api
.
HandleFunc
)
http
.
Handler
{
return
myAPI
.
PreAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
api
.
Response
)
{
if
a
.
StoreLFSPath
==
""
{
...
...
internal/upload/uploads.go
View file @
fb1df36e
...
...
@@ -86,8 +86,8 @@ func rewriteFormFilesFromMultipart(r *http.Request, writer *multipart.Writer, te
return
cleanup
,
nil
}
func
handleFileUploads
(
h
http
.
Handler
)
http
.
Handler
Func
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
handleFileUploads
(
h
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
tempPath
:=
r
.
Header
.
Get
(
tempPathHeader
)
if
tempPath
==
""
{
helper
.
Fail500
(
w
,
errors
.
New
(
"handleFileUploads: TempPath empty"
))
...
...
@@ -124,5 +124,5 @@ func handleFileUploads(h http.Handler) http.HandlerFunc {
// Proxy the request
h
.
ServeHTTP
(
w
,
r
)
}
}
)
}
internal/upstream/handlers.go
View file @
fb1df36e
...
...
@@ -8,8 +8,8 @@ import (
"net/http"
)
func
contentEncodingHandler
(
h
http
.
Handler
)
http
.
Handler
Func
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
contentEncodingHandler
(
h
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
body
io
.
ReadCloser
var
err
error
...
...
@@ -34,5 +34,5 @@ func contentEncodingHandler(h http.Handler) http.HandlerFunc {
r
.
Header
.
Del
(
"Content-Encoding"
)
h
.
ServeHTTP
(
w
,
r
)
}
}
)
}
internal/upstream/handlers_test.go
View file @
fb1df36e
...
...
@@ -35,7 +35,7 @@ func TestGzipEncoding(t *testing.T) {
if
r
.
Header
.
Get
(
"Content-Encoding"
)
!=
""
{
t
.
Fatal
(
"Content-Encoding should be deleted"
)
}
}))(
resp
,
req
)
}))
.
ServeHTTP
(
resp
,
req
)
helper
.
AssertResponseCode
(
t
,
resp
,
200
)
}
...
...
@@ -59,7 +59,7 @@ func TestNoEncoding(t *testing.T) {
if
r
.
Header
.
Get
(
"Content-Encoding"
)
!=
""
{
t
.
Fatal
(
"Content-Encoding should be deleted"
)
}
}))(
resp
,
req
)
}))
.
ServeHTTP
(
resp
,
req
)
helper
.
AssertResponseCode
(
t
,
resp
,
200
)
}
...
...
@@ -75,7 +75,7 @@ func TestInvalidEncoding(t *testing.T) {
contentEncodingHandler
(
http
.
HandlerFunc
(
func
(
_
http
.
ResponseWriter
,
_
*
http
.
Request
)
{
t
.
Fatal
(
"it shouldn't be executed"
)
}))(
resp
,
req
)
}))
.
ServeHTTP
(
resp
,
req
)
helper
.
AssertResponseCode
(
t
,
resp
,
500
)
}
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