goproxy

package module
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2019 License: MIT Imports: 7 Imported by: 1

README

GoProxy middleware

Middleware for go modules proxy, inspired by https://github.com/goproxyio/goproxy

Usage

How to set up a middleware:

  1. Initiate router:
    r, err := router.NewRouter()
    
  2. Add needed handlers via
    err := r.AddRoute(proxyFactory)
    
    for example:
    regular, err := vcs.NewFactory(cacheDir)
    if err != nil {
        log.Fatal(err)
    }
    if err := r.AddRoute("", regular); err != nil {
        log.Fatal(err)
    }
    
    this library currently supports vcs which is pretty much like regular go get (regular in the example), gitlab which works upon gitlab's v4 API and delegation to another go proxy, see source/...
  3. Generate middleware:
    var m http.Handler = goproxy.Middleware(r)
    
    Now you can use it in your HTTP server See examples/goproxy for details

Example

There's an example which supports regular go get-like module retrieval and gitlab.

  1. Build it:
    go build ./examples/goproxy
    
  2. Start it:
    ./goproxy -cache-dir . -gitlab https://gitlab.com/api/v4 -listen 0.0.0.0:8081
    
  3. Set up environment:
    export GO111MODULE=on
    export GOPROXY=http://<gitlab private token>@localhost:8081
    
    Remember, you must generate gitlab private token first otherwise gitlab may reject your requests

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(r *router.Router, transportPrefix string, logger *zerolog.Logger) http.Handler

Middleware acts as go proxy with given router.

transportPrefix is a head part of URL path which refers to address of go proxy before the module info. For example,

if we serving go proxy at https://0.0.0.0:8081/goproxy/..., transportPrefix will be "/goproxy"

Types

This section is empty.

Directories

Path Synopsis
examples
internal
base
Package base defines shared basic pieces of the go command, in particular logging and the Command structure.
Package base defines shared basic pieces of the go command, in particular logging and the Command structure.
browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
bug
Package bug implements the “go bug” command.
Package bug implements the “go bug” command.
cache
Package cache implements a build artifact cache.
Package cache implements a build artifact cache.
cfg
Package cfg holds configuration shared by multiple parts of the go command.
Package cfg holds configuration shared by multiple parts of the go command.
clean
Package clean implements the “go clean” command.
Package clean implements the “go clean” command.
cmdflag
Package cmdflag handles flag processing common to several go tools.
Package cmdflag handles flag processing common to several go tools.
dirhash
Package dirhash defines hashes over directory trees.
Package dirhash defines hashes over directory trees.
doc
Package doc implements the “go doc” command.
Package doc implements the “go doc” command.
envcmd
Package envcmd implements the “go env” command.
Package envcmd implements the “go env” command.
fix
Package fix implements the “go fix” command.
Package fix implements the “go fix” command.
fmtcmd
Package fmtcmd implements the “go fmt” command.
Package fmtcmd implements the “go fmt” command.
generate
Package generate implements the “go generate” command.
Package generate implements the “go generate” command.
get
Package get implements the “go get” command.
Package get implements the “go get” command.
help
Package help implements the “go help” command.
Package help implements the “go help” command.
list
Package list implements the “go list” command.
Package list implements the “go list” command.
load
Package load loads packages.
Package load loads packages.
modcmd
Package modcmd implements the “go mod” command.
Package modcmd implements the “go mod” command.
modfetch/codehost
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
modget
Package modget implements the module-aware “go get” command.
Package modget implements the module-aware “go get” command.
module
Package module defines the module.Version type along with support code.
Package module defines the module.Version type along with support code.
mvs
Package mvs implements Minimal Version Selection.
Package mvs implements Minimal Version Selection.
objabi
Originally, Go object files were Plan 9 object files, but no longer.
Originally, Go object files were Plan 9 object files, but no longer.
par
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
run
Package run implements the “go run” command.
Package run implements the “go run” command.
semver
Package semver implements comparison of semantic version strings.
Package semver implements comparison of semantic version strings.
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
Package singleflight provides a duplicate function call suppression mechanism.
str
Package str provides string manipulation utilities.
Package str provides string manipulation utilities.
test2json
Package test2json implements conversion of test binary output to JSON.
Package test2json implements conversion of test binary output to JSON.
testenv
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
tool
Package tool implements the “go tool” command.
Package tool implements the “go tool” command.
txtar
Package txtar implements a trivial text-based file archive format.
Package txtar implements a trivial text-based file archive format.
version
Package version implements the “go version” command.
Package version implements the “go version” command.
vet
Package vet implements the “go vet” command.
Package vet implements the “go vet” command.
web
Package web defines helper routines for accessing HTTP/HTTPS resources.
Package web defines helper routines for accessing HTTP/HTTPS resources.
vcs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL