Commit d64c1a61 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Rename handleFunc type to httpHandleFunc

parent e783a3d0
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"net/http" "net/http"
) )
func (u *upstream) artifactsAuthorizeHandler(h handleFunc) handleFunc { func (u *upstream) artifactsAuthorizeHandler(h httpHandleFunc) httpHandleFunc {
return u.preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) { return u.preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) {
req := r.Request req := r.Request
req.Header.Set(tempPathHeader, r.TempPath) req.Header.Set(tempPathHeader, r.TempPath)
......
...@@ -51,7 +51,7 @@ func (u *upstream) newUpstreamRequest(r *http.Request, body io.Reader, suffix st ...@@ -51,7 +51,7 @@ func (u *upstream) newUpstreamRequest(r *http.Request, body io.Reader, suffix st
return authReq, nil return authReq, nil
} }
func (u *upstream) preAuthorizeHandler(h serviceHandleFunc, suffix string) handleFunc { func (u *upstream) preAuthorizeHandler(h serviceHandleFunc, suffix string) httpHandleFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
authReq, err := u.newUpstreamRequest(r, nil, suffix) authReq, err := u.newUpstreamRequest(r, nil, suffix)
if err != nil { if err != nil {
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"path/filepath" "path/filepath"
) )
func handleDeployPage(documentRoot *string, handler handleFunc) handleFunc { func handleDeployPage(documentRoot *string, handler httpHandleFunc) httpHandleFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
deployPage := filepath.Join(*documentRoot, "index.html") deployPage := filepath.Join(*documentRoot, "index.html")
data, err := ioutil.ReadFile(deployPage) data, err := ioutil.ReadFile(deployPage)
......
...@@ -2,7 +2,7 @@ package main ...@@ -2,7 +2,7 @@ package main
import "net/http" import "net/http"
func handleDevelopmentMode(developmentMode *bool, handler handleFunc) handleFunc { func handleDevelopmentMode(developmentMode *bool, handler httpHandleFunc) httpHandleFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
if !*developmentMode { if !*developmentMode {
http.NotFound(w, r) http.NotFound(w, r)
......
...@@ -59,7 +59,7 @@ func (s *errorPageResponseWriter) Flush() { ...@@ -59,7 +59,7 @@ func (s *errorPageResponseWriter) Flush() {
s.WriteHeader(http.StatusOK) s.WriteHeader(http.StatusOK)
} }
func handleRailsError(documentRoot *string, handler handleFunc) handleFunc { func handleRailsError(documentRoot *string, handler httpHandleFunc) httpHandleFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
rw := errorPageResponseWriter{ rw := errorPageResponseWriter{
rw: w, rw: w,
......
...@@ -26,7 +26,7 @@ func looksLikeRepo(p string) bool { ...@@ -26,7 +26,7 @@ func looksLikeRepo(p string) bool {
return true return true
} }
func (u *upstream) repoPreAuthorizeHandler(handleFunc serviceHandleFunc) handleFunc { func (u *upstream) repoPreAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc {
return u.preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) { return u.preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) {
if r.RepoPath == "" { if r.RepoPath == "" {
fail500(w, errors.New("repoPreAuthorizeHandler: RepoPath empty")) fail500(w, errors.New("repoPreAuthorizeHandler: RepoPath empty"))
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"net/http" "net/http"
) )
func contentEncodingHandler(h handleFunc) handleFunc { func contentEncodingHandler(h httpHandleFunc) httpHandleFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
var body io.ReadCloser var body io.ReadCloser
var err error var err error
......
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
"path/filepath" "path/filepath"
) )
func (u *upstream) lfsAuthorizeHandler(handleFunc serviceHandleFunc) handleFunc { func (u *upstream) lfsAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc {
return u.preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) { return u.preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) {
if r.StoreLFSPath == "" { if r.StoreLFSPath == "" {
......
...@@ -43,10 +43,10 @@ var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets ...@@ -43,10 +43,10 @@ var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets
type httpRoute struct { type httpRoute struct {
method string method string
regex *regexp.Regexp regex *regexp.Regexp
handleFunc handleFunc handleFunc httpHandleFunc
} }
type handleFunc func(http.ResponseWriter, *http.Request) type httpHandleFunc func(http.ResponseWriter, *http.Request)
const projectPattern = `^/[^/]+/[^/]+/` const projectPattern = `^/[^/]+/[^/]+/`
const gitProjectPattern = `^/[^/]+/[^/]+\.git/` const gitProjectPattern = `^/[^/]+/[^/]+\.git/`
......
...@@ -16,7 +16,7 @@ const ( ...@@ -16,7 +16,7 @@ const (
CacheExpireMax CacheExpireMax
) )
func (u *upstream) handleServeFile(documentRoot *string, cache CacheMode, notFoundHandler handleFunc) handleFunc { func (u *upstream) handleServeFile(documentRoot *string, cache CacheMode, notFoundHandler httpHandleFunc) httpHandleFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
file := filepath.Join(*documentRoot, u.relativeURIPath(cleanURIPath(r.URL.Path))) file := filepath.Join(*documentRoot, u.relativeURIPath(cleanURIPath(r.URL.Path)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment