OpenAPI docs

This commit is contained in:
Denis Arh
2020-11-05 19:13:26 +01:00
parent eca90b1fc1
commit bfdb1d8426
13 changed files with 4773 additions and 3401 deletions
+18
View File
@@ -0,0 +1,18 @@
package api
import (
"fmt"
"github.com/cortezaproject/corteza-server/docs"
"github.com/goware/statik/fs"
"net/http"
)
func serveDocs(w http.ResponseWriter, r *http.Request) {
root, err := fs.New(docs.Asset)
if err != nil {
http.Error(w, fmt.Sprintf("could not read embeded filesystem: %v", err.Error()), http.StatusInternalServerError)
return
}
http.StripPrefix("/docs", http.FileServer(root)).ServeHTTP(w, r)
}
+18
View File
@@ -0,0 +1,18 @@
package server
import (
"fmt"
"github.com/cortezaproject/corteza-server/docs"
"github.com/goware/statik/fs"
"net/http"
)
func serveDocs(w http.ResponseWriter, r *http.Request) {
root, err := fs.New(docs.Asset)
if err != nil {
http.Error(w, fmt.Sprintf("could not read embeded filesystem: %v", err.Error()), http.StatusInternalServerError)
return
}
http.StripPrefix("/docs", http.FileServer(root)).ServeHTTP(w, r)
}
+3
View File
@@ -143,4 +143,7 @@ func (s server) bindMiscRoutes(router chi.Router) {
if s.httpOpt.EnableHealthcheckRoute {
router.Get("/healthcheck", healthcheck.HttpHandler())
}
//router.Group(serveDocs2)
router.HandleFunc("/docs*", serveDocs)
}