Add gems remote type for RubyGems
- add gems package type proxying the compact index and .gem/quick gemspec downloads - route HEAD on /api/v1/remote/* so gem detects the compact index
This commit is contained in:
@@ -40,6 +40,7 @@ func NewProxyHandler(engine *proxy.Engine, virtualEngine *virtual.Engine, db *da
|
||||
func (h *ProxyHandler) Routes() chi.Router {
|
||||
r := chi.NewRouter()
|
||||
r.Get("/remote/{remoteName}/*", h.handleProxy)
|
||||
r.Head("/remote/{remoteName}/*", h.handleProxyHead)
|
||||
r.Get("/local/{localName}/*", h.handleLocal)
|
||||
r.Get("/virtual/{virtualName}/*", h.handleVirtual)
|
||||
return r
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func TestRoutesRemoteHead(t *testing.T) {
|
||||
r := (&ProxyHandler{}).Routes()
|
||||
for _, m := range []string{http.MethodGet, http.MethodHead} {
|
||||
if !r.Match(chi.NewRouteContext(), m, "/remote/rubygems/versions") {
|
||||
t.Errorf("%s /remote/rubygems/versions not routed", m)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user