add /api/version
This commit is contained in:
parent
ff2a9e21b5
commit
b740ccc74e
|
@ -123,6 +123,8 @@ Authentication: Bearer <token>
|
||||||
|
|
||||||
Here's the API, in brief:
|
Here's the API, in brief:
|
||||||
|
|
||||||
|
Base URL looks like `https://example.com/api`.
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
# Demo Mode Only
|
# Demo Mode Only
|
||||||
DELETE /public/reset Drop database and re-initialize
|
DELETE /public/reset Drop database and re-initialize
|
||||||
|
|
12
main.go
12
main.go
|
@ -33,7 +33,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
ver()
|
fmt.Println(ver())
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println("Use 'help <command>'")
|
fmt.Println("Use 'help <command>'")
|
||||||
fmt.Println(" help")
|
fmt.Println(" help")
|
||||||
|
@ -41,8 +41,8 @@ func usage() {
|
||||||
fmt.Println(" run")
|
fmt.Println(" run")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ver() {
|
func ver() string {
|
||||||
fmt.Printf("%s v%s %s (%s)\n", name, version, commit[:7], date)
|
return fmt.Sprintf("%s v%s %s (%s)\n", name, version, commit[:7], date)
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultAddr = ":3000"
|
var defaultAddr = ":3000"
|
||||||
|
@ -113,7 +113,7 @@ func main() {
|
||||||
|
|
||||||
switch args[1] {
|
switch args[1] {
|
||||||
case "version":
|
case "version":
|
||||||
ver()
|
fmt.Println(ver())
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
return
|
return
|
||||||
case "init":
|
case "init":
|
||||||
|
@ -186,6 +186,10 @@ func serve() {
|
||||||
r.Use(middleware.Logger)
|
r.Use(middleware.Logger)
|
||||||
r.Use(middleware.Recoverer)
|
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
|
var pub keypairs.PublicKey = nil
|
||||||
if "" != runOpts.pub {
|
if "" != runOpts.pub {
|
||||||
var err error
|
var err error
|
||||||
|
|
Loading…
Reference in New Issue