Sign inSign up

maxnilz/govanityurls

By maxnilz

•Updated over 7 years ago

Use a custom domain in your Go import path, forked & modified from GCP/govanityurls

Image
0

930

maxnilz/govanityurls repository overview

⁠Go Vanity URLs

Go Vanity URLs is a simple App Engine Go app that allows you to set custom import paths for your Go packages.

What's the difference between this repo and github.com/GoogleCloudPlatform/govanityurls

  • Remove the gcloud related part
  • Add a dockerfile so that we can use docker to deploy this app anywhere.
  • Modified the README.md, and removed the gcloud related part

⁠Quickstart

Setup a custom domain⁠ for your app.

Get the application:

go get -u -d github.com/maxnilz/govanityurls
cd $(go env GOPATH)/src/github.com/maxnilz/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 with docker:

$ docker build -t govanityurls .
$ docker run -p 80:8080 -v $PWD/vanity.yaml:/etc/vanity.yaml -d govanityurls

Note: Based on the requirements, you might need to setup a proxy on port 80 which will redirect the traffic to the default listen port 8080

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

$ go get customdomain.com/portmidi

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
KeyRequiredDescription
cache_max_ageoptionalThe amount of time to cache package pages in seconds. Controls the max-age directive sent in the Cache-Control⁠ HTTP header.
hostoptionalHost 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⁠.
pathsrequiredMap 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
KeyRequiredDescription
displayoptionalThe last three fields of the go-source meta tag⁠. If omitted, it is inferred from the code hosting service if possible.
reporequiredRoot URL of the repository as it would appear in go-import meta tag⁠.
vcsrequired if ambiguousIf 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.

Tag summary

Content type

Image

Digest

Size

8.6 MB

Last updated

over 7 years ago

docker pull maxnilz/govanityurls