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
9f0b3f71
Commit
9f0b3f71
authored
Jan 13, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use eager initialization for Upstream.URLPrefix
parent
a202aadc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
20 deletions
+15
-20
internal/upstream/routes.go
internal/upstream/routes.go
+2
-2
internal/upstream/upstream.go
internal/upstream/upstream.go
+13
-18
No files found.
internal/upstream/routes.go
View file @
9f0b3f71
...
...
@@ -73,7 +73,7 @@ func (u *Upstream) configureRoutes() {
// Serve assets
route
{
""
,
regexp
.
MustCompile
(
`^/assets/`
),
static
.
ServeExisting
(
u
.
URLPrefix
()
,
staticpages
.
CacheExpireMax
,
static
.
ServeExisting
(
u
.
URLPrefix
,
staticpages
.
CacheExpireMax
,
NotFoundUnless
(
u
.
DevelopmentMode
,
proxy
,
),
...
...
@@ -88,7 +88,7 @@ func (u *Upstream) configureRoutes() {
// Serve static files or forward the requests
route
{
""
,
nil
,
static
.
ServeExisting
(
u
.
URLPrefix
()
,
staticpages
.
CacheDisabled
,
static
.
ServeExisting
(
u
.
URLPrefix
,
staticpages
.
CacheDisabled
,
static
.
DeployPage
(
static
.
ErrorPages
(
u
.
DevelopmentMode
,
proxy
,
...
...
internal/upstream/upstream.go
View file @
9f0b3f71
...
...
@@ -28,9 +28,7 @@ type Upstream struct {
DevelopmentMode
bool
ProxyHeadersTimeout
time
.
Duration
urlPrefix
urlprefix
.
Prefix
configureURLPrefixOnce
sync
.
Once
URLPrefix
urlprefix
.
Prefix
Routes
[]
route
roundtripper
*
badgateway
.
RoundTripper
...
...
@@ -46,23 +44,20 @@ func NewUpstream(backend *url.URL, socket string, version string, documentRoot s
DevelopmentMode
:
developmentMode
,
ProxyHeadersTimeout
:
proxyHeadersTimeout
,
}
if
backend
==
nil
{
up
.
Backend
=
DefaultBackend
}
up
.
configureRoutes
()
up
.
configureURLPrefix
()
return
&
up
}
func
(
u
*
Upstream
)
URLPrefix
()
urlprefix
.
Prefix
{
u
.
configureURLPrefixOnce
.
Do
(
func
()
{
if
u
.
Backend
==
nil
{
u
.
Backend
=
DefaultBackend
}
func
(
u
*
Upstream
)
configureURLPrefix
()
{
relativeURLRoot
:=
u
.
Backend
.
Path
if
!
strings
.
HasSuffix
(
relativeURLRoot
,
"/"
)
{
relativeURLRoot
+=
"/"
}
u
.
urlPrefix
=
urlprefix
.
Prefix
(
relativeURLRoot
)
})
return
u
.
urlPrefix
u
.
URLPrefix
=
urlprefix
.
Prefix
(
relativeURLRoot
)
}
func
(
u
*
Upstream
)
RoundTripper
()
*
badgateway
.
RoundTripper
{
...
...
@@ -94,7 +89,7 @@ func (u *Upstream) ServeHTTP(ow http.ResponseWriter, r *http.Request) {
// Check URL Root
URIPath
:=
urlprefix
.
CleanURIPath
(
r
.
URL
.
Path
)
prefix
:=
u
.
URLPrefix
()
prefix
:=
u
.
URLPrefix
if
!
prefix
.
Match
(
URIPath
)
{
httpError
(
&
w
,
r
,
fmt
.
Sprintf
(
"Not found %q"
,
URIPath
),
http
.
StatusNotFound
)
return
...
...
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