-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
Hello everyone,
I think this might be a simple issue, but I can't figure out what's wrong. I'm trying to integrate Swagger with Gorilla Mux, but whenever I try to access the Swagger UI, I get a "404 Page Not Found" error.
Here's the code I'm using:
package main
import (
"fmt"
"log"
"net/http"
_ "my-project/api/docs"
"github.com/gorilla/mux"
httpSwagger "github.com/swaggo/http-swagger/v2"
)
// @title Swagger Example API
// @version 1.0
// @description test.
// @tag.name test
// @tag.description test
// @tag.docs.url https://example.com
// @tag.docs.description Best example documentation
// @termsOfService http://swagger.io/terms/
// @contact.name Azzam Syakir
// @contact.url https://github.com/AzzamSyakir
// @contact.email azzam.sykir.work@gmail.com
// @host localhost:8080
func main() {
r := mux.NewRouter()
r.PathPrefix("/swagger/*").Handler(httpSwagger.Handler(
httpSwagger.URL("http://localhost:1323/api/docs/doc.json"), //The url pointing to API definition
httpSwagger.DeepLinking(true),
httpSwagger.DocExpansion("none"),
httpSwagger.DomID("swagger-ui"),
)).Methods(http.MethodGet)
fmt.Println("start")
log.Fatal(http.ListenAndServe(":1323", r))
fmt.Println("finish")
}
Metadata
Metadata
Assignees
Labels
No labels