Permalink
Browse files

Use statik for swaggerui

  • Loading branch information...
ribice committed Jun 11, 2018
1 parent 12b6b85 commit 43deebabb44b820652aeda1ce24628ad99e759c4
@@ -35,21 +35,29 @@ import (
"log"
"net/http"
"github.com/rakyll/statik/fs"
"github.com/ribice/golang-swaggerui-example/cmd/api"
_ "github.com/ribice/golang-swaggerui-example/cmd/swagger"
_ "github.com/ribice/golang-swaggerui-example/cmd/swaggerui" // statik files
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter().StrictSlash(true)
statikFS, err := fs.New()
if err != nil {
panic(err)
}
staticServer := http.FileServer(statikFS)
sh := http.StripPrefix("/swaggerui/", staticServer)
router.PathPrefix("/swaggerui/").Handler(sh)
registerV1Routes(router)
log.Fatal(http.ListenAndServe(":8080", router))
}
func registerV1Routes(r *mux.Router) {
sh := http.StripPrefix("/swaggerui/", http.FileServer(http.Dir("./cmd/swaggerui/")))
r.PathPrefix("/swaggerui/").Handler(sh)
v1 := r.PathPrefix("/v1").Subrouter()
api.RegisterRepoRoutes(v1, "/repo")
api.RegisterUserRoutes(v1, "/user")
Binary file not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 43deeba

Please sign in to comment.