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
b0525d6c
Commit
b0525d6c
authored
Dec 17, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compile routes later during boot
parent
bd5ec001
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
45 deletions
+51
-45
main.go
main.go
+50
-45
main_test.go
main_test.go
+1
-0
No files found.
main.go
View file @
b0525d6c
...
@@ -57,57 +57,61 @@ const ciAPIPattern = `^/ci/api/`
...
@@ -57,57 +57,61 @@ const ciAPIPattern = `^/ci/api/`
// Routing table
// Routing table
// We match against URI not containing the relativeUrlRoot:
// We match against URI not containing the relativeUrlRoot:
// see upstream.ServeHTTP
// see upstream.ServeHTTP
var
httpRoutes
=
[
...
]
httpRoute
{
var
httpRoutes
[]
httpRoute
// Git Clone
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`info/refs\z`
),
repoPreAuthorizeHandler
(
handleGetInfoRefs
)},
func
compileRoutes
()
{
httpRoute
{
"POST"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`git-upload-pack\z`
),
repoPreAuthorizeHandler
(
contentEncodingHandler
(
handlePostRPC
))},
httpRoutes
=
[]
httpRoute
{
httpRoute
{
"POST"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`git-receive-pack\z`
),
repoPreAuthorizeHandler
(
contentEncodingHandler
(
handlePostRPC
))},
// Git Clone
httpRoute
{
"PUT"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`
),
lfsAuthorizeHandler
(
handleStoreLfsObject
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`info/refs\z`
),
repoPreAuthorizeHandler
(
handleGetInfoRefs
)},
httpRoute
{
"POST"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`git-upload-pack\z`
),
repoPreAuthorizeHandler
(
contentEncodingHandler
(
handlePostRPC
))},
// Repository Archive
httpRoute
{
"POST"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`git-receive-pack\z`
),
repoPreAuthorizeHandler
(
contentEncodingHandler
(
handlePostRPC
))},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"PUT"
,
regexp
.
MustCompile
(
gitProjectPattern
+
`gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`
),
lfsAuthorizeHandler
(
handleStoreLfsObject
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.zip\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.tar\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
// Repository Archive
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.tar.gz\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.tar.bz2\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.zip\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.tar\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
// Repository Archive API
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.tar.gz\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectPattern
+
`repository/archive.tar.bz2\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.zip\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
// Repository Archive API
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar.gz\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar.bz2\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.zip\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
// CI Artifacts API
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar.gz\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
httpRoute
{
"POST"
,
regexp
.
MustCompile
(
ciAPIPattern
+
`v1/builds/[0-9]+/artifacts\z`
),
artifactsAuthorizeHandler
(
contentEncodingHandler
(
handleFileUploads
))},
httpRoute
{
"GET"
,
regexp
.
MustCompile
(
projectsAPIPattern
+
`repository/archive.tar.bz2\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
// Explicitly proxy API requests
// CI Artifacts API
httpRoute
{
""
,
regexp
.
MustCompile
(
apiPattern
),
proxyRequest
},
httpRoute
{
"POST"
,
regexp
.
MustCompile
(
ciAPIPattern
+
`v1/builds/[0-9]+/artifacts\z`
),
artifactsAuthorizeHandler
(
contentEncodingHandler
(
handleFileUploads
))},
httpRoute
{
""
,
regexp
.
MustCompile
(
ciAPIPattern
),
proxyRequest
},
// Explicitly proxy API requests
// Serve assets
httpRoute
{
""
,
regexp
.
MustCompile
(
apiPattern
),
proxyRequest
},
httpRoute
{
""
,
regexp
.
MustCompile
(
`^/assets/`
),
httpRoute
{
""
,
regexp
.
MustCompile
(
ciAPIPattern
),
proxyRequest
},
handleServeFile
(
documentRoot
,
CacheExpireMax
,
handleDevelopmentMode
(
developmentMode
,
// Serve assets
httpRoute
{
""
,
regexp
.
MustCompile
(
`^/assets/`
),
handleServeFile
(
documentRoot
,
CacheExpireMax
,
handleDevelopmentMode
(
developmentMode
,
handleDeployPage
(
documentRoot
,
handleRailsError
(
documentRoot
,
proxyRequest
,
),
),
),
),
},
// Serve static files or forward the requests
httpRoute
{
""
,
nil
,
handleServeFile
(
documentRoot
,
CacheDisabled
,
handleDeployPage
(
documentRoot
,
handleDeployPage
(
documentRoot
,
handleRailsError
(
documentRoot
,
handleRailsError
(
documentRoot
,
proxyRequest
,
proxyRequest
,
),
),
),
),
),
),
),
},
},
}
// Serve static files or forward the requests
httpRoute
{
""
,
nil
,
handleServeFile
(
documentRoot
,
CacheDisabled
,
handleDeployPage
(
documentRoot
,
handleRailsError
(
documentRoot
,
proxyRequest
,
),
),
),
},
}
}
func
main
()
{
func
main
()
{
...
@@ -169,5 +173,6 @@ func main() {
...
@@ -169,5 +173,6 @@ func main() {
}
}
upstream
:=
newUpstream
(
*
authBackend
,
proxyTransport
)
upstream
:=
newUpstream
(
*
authBackend
,
proxyTransport
)
compileRoutes
()
log
.
Fatal
(
http
.
Serve
(
listener
,
upstream
))
log
.
Fatal
(
http
.
Serve
(
listener
,
upstream
))
}
}
main_test.go
View file @
b0525d6c
...
@@ -326,6 +326,7 @@ func testAuthServer(url *regexp.Regexp, code int, body interface{}) *httptest.Se
...
@@ -326,6 +326,7 @@ func testAuthServer(url *regexp.Regexp, code int, body interface{}) *httptest.Se
}
}
func
startWorkhorseServer
(
authBackend
string
)
*
httptest
.
Server
{
func
startWorkhorseServer
(
authBackend
string
)
*
httptest
.
Server
{
compileRoutes
()
return
httptest
.
NewServer
(
newUpstream
(
authBackend
,
nil
))
return
httptest
.
NewServer
(
newUpstream
(
authBackend
,
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