projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
8016: Fix comment grammar and weird variable name.
[arvados.git]
/
services
/
arv-git-httpd
/
auth_handler.go
diff --git
a/services/arv-git-httpd/auth_handler.go
b/services/arv-git-httpd/auth_handler.go
index 741e543850709ca1f075751597778e0e7ef769d0..fccb0c9576864634481a2e69b7237def54b6f0ec 100644
(file)
--- a/
services/arv-git-httpd/auth_handler.go
+++ b/
services/arv-git-httpd/auth_handler.go
@@
-3,10
+3,8
@@
package main
import (
"log"
"net/http"
import (
"log"
"net/http"
- "net/http/cgi"
"os"
"strings"
"os"
"strings"
- "sync"
"time"
"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
"time"
"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
@@
-14,19
+12,10
@@
import (
"git.curoverse.com/arvados.git/sdk/go/httpserver"
)
"git.curoverse.com/arvados.git/sdk/go/httpserver"
)
-func newArvadosClient() interface{} {
- arv, err := arvadosclient.MakeArvadosClient()
- if err != nil {
- log.Println("MakeArvadosClient:", err)
- return nil
- }
- return &arv
-}
-
-var connectionPool = &sync.Pool{New: newArvadosClient}
+var clientPool = arvadosclient.MakeClientPool()
type authHandler struct {
type authHandler struct {
- handler
*cgi
.Handler
+ handler
http
.Handler
}
func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
}
func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
@@
-79,12
+68,12
@@
func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
repoName = pathParts[0]
repoName = strings.TrimRight(repoName, "/")
repoName = pathParts[0]
repoName = strings.TrimRight(repoName, "/")
- arv
, ok := connectionPool.Get().(*arvadosclient.ArvadosClient
)
- if
!ok ||
arv == nil {
- statusCode, statusText = http.StatusInternalServerError, "connection pool failed
"
+ arv
:= clientPool.Get(
)
+ if arv == nil {
+ statusCode, statusText = http.StatusInternalServerError, "connection pool failed
: "+clientPool.Err().Error()
return
}
return
}
- defer c
onnection
Pool.Put(arv)
+ defer c
lient
Pool.Put(arv)
// Ask API server whether the repository is readable using
// this token (by trying to read it!)
// Ask API server whether the repository is readable using
// this token (by trying to read it!)
@@
-160,7
+149,5
@@
func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
}
r.URL.Path = rewrittenPath
}
r.URL.Path = rewrittenPath
- handlerCopy := *h.handler
- handlerCopy.Env = append(handlerCopy.Env, "REMOTE_USER="+r.RemoteAddr) // Should be username
- handlerCopy.ServeHTTP(&w, r)
+ h.handler.ServeHTTP(&w, r)
}
}