Skip to content

Commit e749108

Browse files
zombiezenJaana B. Dogan
authored and
Jaana B. Dogan
committed
README: document new features (GoogleCloudPlatform#8)
Add reference section for configuration file and note that the server can run in other compute environments. Tweaked main.go slightly to default to using vanity.yaml for App Engine Flex.
1 parent c5fd584 commit e749108

File tree

2 files changed

+84
-3
lines changed

2 files changed

+84
-3
lines changed

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,78 @@ That's it! You can use `go get` to get the package from your custom domain.
4141
```
4242
$ go get customdomain.com/portmidi
4343
```
44+
45+
### Running in other environments
46+
47+
You can also deploy this as an App Engine Flexible app by changing the
48+
`app.yaml` file:
49+
50+
```
51+
runtime: go
52+
env: flex
53+
```
54+
55+
This project is a normal Go HTTP server, so you can also incorporate the
56+
handler into larger Go servers.
57+
58+
## Configuration File
59+
60+
```
61+
host: example.com
62+
paths:
63+
/foo:
64+
repo: https://github.com/example/foo
65+
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}"
66+
vcs: git
67+
```
68+
69+
<table>
70+
<thead>
71+
<tr>
72+
<th scope="col">Key</th>
73+
<th scope="col">Required</th>
74+
<th scope="col">Description</th>
75+
</tr>
76+
</thead>
77+
<tbody>
78+
<tr>
79+
<th scope="row"><code>host</code></th>
80+
<td>optional</td>
81+
<td>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 <a href="https://cloud.google.com/appengine/docs/standard/go/how-requests-are-routed#routing_with_a_dispatch_file">custom dispatch file</a>.</td>
82+
</tr>
83+
<tr>
84+
<th scope="row"><code>paths</code></th>
85+
<td>required</td>
86+
<td>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.</td>
87+
</tr>
88+
</tbody>
89+
</table>
90+
91+
### Path Configuration
92+
93+
<table>
94+
<thead>
95+
<tr>
96+
<th scope="col">Key</th>
97+
<th scope="col">Required</th>
98+
<th scope="col">Description</th>
99+
</tr>
100+
</thead>
101+
<tbody>
102+
<tr>
103+
<th scope="row"><code>display</code></th>
104+
<td>optional</td>
105+
<td>The last three fields of the <a href="https://github.com/golang/gddo/wiki/Source-Code-Links"><code>go-source</code> meta tag</a>. If omitted, it is inferred from the code hosting service if possible.</td>
106+
</tr>
107+
<tr>
108+
<th scope="row"><code>repo</code></th>
109+
<td>required</td>
110+
<td>Root URL of the repository as it would appear in <a href="https://golang.org/cmd/go/#hdr-Remote_import_paths"><code>go-import</code> meta tag</a>.</td>
111+
</tr>
112+
<tr>
113+
<th scope="row"><code>vcs</code></th>
114+
<td>required if ambiguous</td>
115+
<td>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 <a href="https://golang.org/cmd/go/#hdr-Remote_import_paths"><code>go-import</code> meta tag</a>. This can be one of <code>git</code>, <code>hg</code>, <code>svn</code>, or <code>bzr</code>.</td>
116+
</tr>
117+
</tbody>
118+
</table>

main.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ import (
2424
)
2525

2626
func main() {
27-
if len(os.Args) != 2 {
28-
log.Fatal("usage: govanityurls CONFIG")
27+
var configPath string
28+
switch len(os.Args) {
29+
case 1:
30+
configPath = "vanity.yaml"
31+
case 2:
32+
configPath = os.Args[1]
33+
default:
34+
log.Fatal("usage: govanityurls [CONFIG]")
2935
}
30-
vanity, err := ioutil.ReadFile(os.Args[1])
36+
vanity, err := ioutil.ReadFile(configPath)
3137
if err != nil {
3238
log.Fatal(err)
3339
}

0 commit comments

Comments
 (0)