mirror of
https://github.com/rjNemo/go-microservices-tuto
synced 2026-06-12 13:26:45 +00:00
handle docs route at the router level
This commit is contained in:
parent
13a6e80ce2
commit
270de58204
3 changed files with 11 additions and 3 deletions
|
|
@ -32,7 +32,7 @@ type productResponse struct {
|
||||||
Body models.Product
|
Body models.Product
|
||||||
}
|
}
|
||||||
|
|
||||||
// swagger:parameters deleteProduct updateProduct
|
// swagger:parameters deleteProduct updateProduct getProduct
|
||||||
type productIDParameter struct {
|
type productIDParameter struct {
|
||||||
// The ID of a product in the database
|
// The ID of a product in the database
|
||||||
// in: path
|
// in: path
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,6 @@ func (p *Products) RegisterRoutes(m *mux.Router, path string) {
|
||||||
// swagger docs
|
// swagger docs
|
||||||
opts := middleware.RedocOpts{SpecURL: "/swagger.yaml"}
|
opts := middleware.RedocOpts{SpecURL: "/swagger.yaml"}
|
||||||
swaggerHandler := middleware.Redoc(opts, nil)
|
swaggerHandler := middleware.Redoc(opts, nil)
|
||||||
getRouter.Handle("/docs", swaggerHandler)
|
m.Handle("/docs", swaggerHandler).Methods(http.MethodGet)
|
||||||
getRouter.Handle("/swagger.yaml", http.FileServer(http.Dir("./")))
|
m.Handle("/swagger.yaml", http.FileServer(http.Dir("./")))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,14 @@ paths:
|
||||||
get:
|
get:
|
||||||
description: Return a list of products from the database
|
description: Return a list of products from the database
|
||||||
operationId: getProduct
|
operationId: getProduct
|
||||||
|
parameters:
|
||||||
|
- description: The ID of a product in the database
|
||||||
|
format: int64
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
x-go-name: ID
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
$ref: '#/responses/productResponse'
|
$ref: '#/responses/productResponse'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue