diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-05-29 11:43:40 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-05-29 11:43:40 -0700 |
commit | 0c395e5df3f82037fbdc6076df87d81ea5921574 (patch) | |
tree | 4a59f17b554514c558fcfd57ecb7ca7728556675 /system | |
parent | abf2c7e97b45ca9c90f0f3b3d1b6272d3ee4370b (diff) |
adding --docs and --docs-port flags to config and run local docs server
Diffstat (limited to 'system')
-rw-r--r-- | system/admin/server.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/system/admin/server.go b/system/admin/server.go index 426dabd..9f28a0d 100644 --- a/system/admin/server.go +++ b/system/admin/server.go @@ -1,6 +1,7 @@ package admin import ( + "fmt" "log" "net/http" "os" @@ -62,3 +63,23 @@ func Run() { // Database & uploads backup via HTTP route registered with Basic Auth middleware. http.HandleFunc("/admin/backup", system.BasicAuth(backupHandler)) } + +// Docs adds the documentation file server to the server, accessible at +// http://localhost:1234 by default +func Docs(port int) { + pwd, err := os.Getwd() + if err != nil { + log.Fatalln("Couldn't find current directory for file server.") + } + + docsDir := filepath.Join(pwd, "docs", "build") + + addr := fmt.Sprintf(":%d", port) + url := fmt.Sprintf("http://localhost%s", addr) + + fmt.Println("") + fmt.Println("View documentation offline at:", url) + fmt.Println("") + + go http.ListenAndServe(addr, http.FileServer(http.Dir(docsDir))) +} |