Commit 70f191d2 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Move lfs into internal/lfs package

parent eba05966
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
In this file we handle git lfs objects downloads and uploads In this file we handle git lfs objects downloads and uploads
*/ */
package main package lfs
import ( import (
"./internal/api" "../api"
"./internal/helper" "../helper"
"../proxy"
"bytes" "bytes"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
...@@ -19,6 +20,10 @@ import ( ...@@ -19,6 +20,10 @@ import (
"path/filepath" "path/filepath"
) )
func PutStore(a *api.API, p *proxy.Proxy) http.HandlerFunc {
return lfsAuthorizeHandler(a, handleStoreLfsObject(p))
}
func lfsAuthorizeHandler(myAPI *api.API, handleFunc api.HandleFunc) http.HandlerFunc { func lfsAuthorizeHandler(myAPI *api.API, handleFunc api.HandleFunc) http.HandlerFunc {
return myAPI.PreAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *api.Response) { return myAPI.PreAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *api.Response) {
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"./internal/api" "./internal/api"
"./internal/errorpage" "./internal/errorpage"
"./internal/git" "./internal/git"
"./internal/lfs"
"./internal/proxy" "./internal/proxy"
"fmt" "fmt"
"log" "log"
...@@ -54,7 +55,7 @@ func (u *upstream) compileRoutes() { ...@@ -54,7 +55,7 @@ func (u *upstream) compileRoutes() {
route{"GET", regexp.MustCompile(gitProjectPattern + `info/refs\z`), git.GetInfoRefs(u.API)}, route{"GET", regexp.MustCompile(gitProjectPattern + `info/refs\z`), git.GetInfoRefs(u.API)},
route{"POST", regexp.MustCompile(gitProjectPattern + `git-upload-pack\z`), contentEncodingHandler(git.PostRPC(u.API))}, route{"POST", regexp.MustCompile(gitProjectPattern + `git-upload-pack\z`), contentEncodingHandler(git.PostRPC(u.API))},
route{"POST", regexp.MustCompile(gitProjectPattern + `git-receive-pack\z`), contentEncodingHandler(git.PostRPC(u.API))}, route{"POST", regexp.MustCompile(gitProjectPattern + `git-receive-pack\z`), contentEncodingHandler(git.PostRPC(u.API))},
route{"PUT", regexp.MustCompile(gitProjectPattern + `gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`), lfsAuthorizeHandler(u.API, handleStoreLfsObject(u.Proxy))}, route{"PUT", regexp.MustCompile(gitProjectPattern + `gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`), lfs.PutStore(u.API, u.Proxy)},
// Repository Archive // Repository Archive
route{"GET", regexp.MustCompile(projectPattern + `repository/archive\z`), git.GetArchive(u.API)}, route{"GET", regexp.MustCompile(projectPattern + `repository/archive\z`), git.GetArchive(u.API)},
......
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