AJ ONeal 4 лет назад
Родитель
Сommit
b740ccc74e
  1. 30
      README.md
  2. 12
      main.go

30
README.md

@ -30,9 +30,9 @@ The platform, publish URL, and token file can be changed in `.goreleaser.yml`:
```yml
env_files:
gitea_token: ~/.config/goreleaser/gitea_token
gitea_token: ~/.config/goreleaser/gitea_token
gitea_urls:
api: https://try.gitea.io/api/v1/
api: https://try.gitea.io/api/v1/
```
#### Manually
@ -67,9 +67,9 @@ GOOS=linux GOARCH=arm64 go build -mod=vendor -o dist/goserv-linux-arm64 .
The example files are located in `./examples`
- Caddyfile (web server config)
- .env (environment variables)
- build.sh
- Caddyfile (web server config)
- .env (environment variables)
- build.sh
```bash
export BASE_URL=https://example.com
@ -123,6 +123,8 @@ Authentication: Bearer <token>
Here's the API, in brief:
Base URL looks like `https://example.com/api`.
```txt
# Demo Mode Only
DELETE /public/reset Drop database and re-initialize
@ -166,9 +168,9 @@ If the documentation is not public hosted you can view it with GoDoc:
godoc --http :6060
```
- <http://localhost:6060/pkg/git.example.com/example/goserv/>
- <http://localhost:6060/pkg/git.example.com/example/goserv/internal/api>
- <http://localhost:6060/pkg/git.example.com/example/goserv/internal/db>
- <http://localhost:6060/pkg/git.example.com/example/goserv/>
- <http://localhost:6060/pkg/git.example.com/example/goserv/internal/api>
- <http://localhost:6060/pkg/git.example.com/example/goserv/internal/db>
You can see abbreviated documentation with `go`'s built-in `doc`, for example:
@ -198,10 +200,10 @@ go test -mod=vendor ./...
This setup can be run on a VPS, such as Digital Ocean, OVH, or Scaleway
for \$5/month with minimal dependencies:
- VPS
- Caddy
- PostgreSQL
- Serviceman
- VPS
- Caddy
- PostgreSQL
- Serviceman
**Mac**, **Linux**:
@ -281,8 +283,8 @@ Copyright 2020 The GoServ Authors. All rights reserved.
### Exceptions
- `countries.json` LGPL, taken from <https://github.com/stefangabos/world_countries>
- `flags.json` MIT, taken from <https://github.com/matiassingers/emoji-flags>
- `countries.json` LGPL, taken from <https://github.com/stefangabos/world_countries>
- `flags.json` MIT, taken from <https://github.com/matiassingers/emoji-flags>
These are probably also in the Public Domain. \
(gathering the official data from any source would yield the same dataset)

12
main.go

@ -33,7 +33,7 @@ var (
)
func usage() {
ver()
fmt.Println(ver())
fmt.Println("")
fmt.Println("Use 'help <command>'")
fmt.Println(" help")
@ -41,8 +41,8 @@ func usage() {
fmt.Println(" run")
}
func ver() {
fmt.Printf("%s v%s %s (%s)\n", name, version, commit[:7], date)
func ver() string {
return fmt.Sprintf("%s v%s %s (%s)\n", name, version, commit[:7], date)
}
var defaultAddr = ":3000"
@ -113,7 +113,7 @@ func main() {
switch args[1] {
case "version":
ver()
fmt.Println(ver())
os.Exit(0)
return
case "init":
@ -186,6 +186,10 @@ func serve() {
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
r.Get("/api/version", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(ver() + "\n"))
})
var pub keypairs.PublicKey = nil
if "" != runOpts.pub {
var err error

Загрузка…
Отмена
Сохранить