Go to file
Marvin Preuss 9093028184
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci: from drone to woodpecker
2022-01-31 12:05:02 +01:00
vendor Update to use app engine runtime go112 (#34) 2020-02-06 09:36:34 -08:00
.travis.yml Update to use app engine runtime go112 (#34) 2020-02-06 09:36:34 -08:00
.woodpecker.yml ci: from drone to woodpecker 2022-01-31 12:05:02 +01:00
app.yaml Update to use app engine runtime go112 (#34) 2020-02-06 09:36:34 -08:00
CONTRIBUTING.md initial commit 2017-06-24 16:39:45 -07:00
Dockerfile adds EXPOSE to dockerfile 2021-01-19 10:21:59 +01:00
go.mod Update to use app engine runtime go112 (#34) 2020-02-06 09:36:34 -08:00
go.sum Update to use app engine runtime go112 (#34) 2020-02-06 09:36:34 -08:00
handler_test.go handler: use longest prefix, shortest subpath matches to query if no route is found (#19) 2018-03-15 13:24:24 -07:00
handler.go handler: use pkg.go.dev instead of golang.org (#33) 2020-02-06 10:48:01 -08:00
LICENSE add LICENSE 2017-06-25 15:24:31 -07:00
main.go Update to use app engine runtime go112 (#34) 2020-02-06 09:36:34 -08:00
README.md Fix go get command (#37) 2020-03-06 09:59:23 -08:00
vanity.yaml add custom domain to vanity.yaml 2017-08-02 22:57:09 -07:00

Go Vanity URLs

Go Vanity URLs is a simple Go server that allows you to set custom import paths for your Go packages. It also can run on Google App Engine.

Quickstart

Install and run the binary:

$ go get -u github.com/GoogleCloudPlatform/govanityurls
$ # update vanity.yaml
$ govanityurls
$ # open http://localhost:8080

Google App Engine

Install gcloud and install Go App Engine component:

$ gcloud components install app-engine-go

Setup a custom domain for your app.

Get the application:

git clone https://github.com/GoogleCloudPlatform/govanityurls
cd govanityurls

Edit vanity.yaml to add any number of git repos. E.g., customdomain.com/portmidi will serve the https://github.com/rakyll/portmidi repo.

paths:
  /portmidi:
    repo: https://github.com/rakyll/portmidi

You can add as many rules as you wish.

Deploy the app:

$ gcloud app deploy

That's it! You can use go get to get the package from your custom domain.

$ go get customdomain.com/portmidi

Running in other environments

You can also deploy this as an App Engine Flexible app by changing the app.yaml file:

runtime: go
env: flex

This project is a normal Go HTTP server, so you can also incorporate the handler into larger Go servers.

Configuration File

host: example.com
cache_max_age: 3600
paths:
  /foo:
    repo: https://github.com/example/foo
    display: "https://github.com/example/foo https://github.com/example/foo/tree/master{/dir} https://github.com/example/foo/blob/master{/dir}/{file}#L{line}"
    vcs: git
Key Required Description
cache_max_age optional The amount of time to cache package pages in seconds. Controls the max-age directive sent in the Cache-Control HTTP header.
host optional Host name to use in meta tags. If omitted, uses the App Engine default version host or the Host header on non-App Engine Standard environments. You can use this option to fix the host when using this service behind a reverse proxy or a custom dispatch file.
paths required Map of paths to path configurations. Each key is a path that will point to the root of a repository hosted elsewhere. The fields are documented in the Path Configuration section below.

Path Configuration

Key Required Description
display optional The last three fields of the go-source meta tag. If omitted, it is inferred from the code hosting service if possible.
repo required Root URL of the repository as it would appear in go-import meta tag.
vcs required if ambiguous If the version control system cannot be inferred (e.g. for Bitbucket or a custom domain), then this specifies the version control system as it would appear in go-import meta tag. This can be one of git, hg, svn, or bzr.