OpenAPI docs
This commit is contained in:
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user