From 88c9ed2643de9f3b9fd2ac9ad03d9e63bd7721d3 Mon Sep 17 00:00:00 2001 From: Bogdan U Date: Fri, 22 Apr 2022 16:50:33 +0300 Subject: [PATCH] chore: add multiple api example (#207) * chore: add multiple api example * chore: update README.md --- README.md | 3 + example/multiple/README.md | 23 +++++++ example/multiple/api/v1/example.go | 26 ++++++++ example/multiple/api/v1/main.go | 25 ++++++++ example/multiple/api/v2/example.go | 26 ++++++++ example/multiple/api/v2/main.go | 25 ++++++++ example/multiple/docs/v1_docs.go | 87 +++++++++++++++++++++++++++ example/multiple/docs/v1_swagger.json | 63 +++++++++++++++++++ example/multiple/docs/v1_swagger.yaml | 42 +++++++++++++ example/multiple/docs/v2_docs.go | 87 +++++++++++++++++++++++++++ example/multiple/docs/v2_swagger.json | 63 +++++++++++++++++++ example/multiple/docs/v2_swagger.yaml | 42 +++++++++++++ example/multiple/main.go | 26 ++++++++ swagger.go | 62 +++++++++---------- swagger_test.go | 17 ++++-- 15 files changed, 581 insertions(+), 36 deletions(-) create mode 100644 example/multiple/README.md create mode 100644 example/multiple/api/v1/example.go create mode 100644 example/multiple/api/v1/main.go create mode 100644 example/multiple/api/v2/example.go create mode 100644 example/multiple/api/v2/main.go create mode 100644 example/multiple/docs/v1_docs.go create mode 100644 example/multiple/docs/v1_swagger.json create mode 100644 example/multiple/docs/v1_swagger.yaml create mode 100644 example/multiple/docs/v2_docs.go create mode 100644 example/multiple/docs/v2_swagger.json create mode 100644 example/multiple/docs/v2_swagger.yaml create mode 100644 example/multiple/main.go diff --git a/README.md b/README.md index 4746631..d610e08 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,9 @@ Demo project tree, `swag init` is run at relative `.` └── main.go ``` +## Multiple APIs +This feature where introduced in swag v1.7.9 + ## Configuration You can configure Swagger using different configuration options diff --git a/example/multiple/README.md b/example/multiple/README.md new file mode 100644 index 0000000..26b0b56 --- /dev/null +++ b/example/multiple/README.md @@ -0,0 +1,23 @@ + +# Multiple API feature +Since swag 1.7.9 we are allowing registration of multiple endpoints into the same server. + +Generate documentation for v1 endpoints +```shell +swag i -g main.go -dir api/v1 --instanceName v1 +``` + + +Generate documentation for v2 endpoints +```shell +swag i -g main.go -dir api/v2 --instanceName v2 +``` + +Run example +```shell + go run main.go +``` + +Now you can access the v1 swagger here [http://localhost:8080/swagger/v1/index.html](http://localhost:8080/swagger/v1/index.html) , +and v2 swagger here [http://localhost:8080/swagger/v2/index.html](http://localhost:8080/swagger/v2/index.html) + diff --git a/example/multiple/api/v1/example.go b/example/multiple/api/v1/example.go new file mode 100644 index 0000000..f000ea1 --- /dev/null +++ b/example/multiple/api/v1/example.go @@ -0,0 +1,26 @@ +package v1 + +import ( + "github.com/gin-gonic/gin" +) + +type Book struct { + ID int `json:"id,omitempty"` + Title string `json:"title"` + Author string `json:"author"` + Year *uint16 `json:"year"` +} + +// +// @Summary Get a list of books in the the store +// @Description get string by ID +// @Accept json +// @Produce json +// @Success 200 {array} Book "ok" +// @Router /books [get] +func GetBooks(ctx *gin.Context) { + ctx.JSON(200, []Book{ + {ID: 1, Title: "Book 1", Author: "Author 1", Year: nil}, + {ID: 2, Title: "Book 2", Author: "Author 2", Year: nil}, + }) +} diff --git a/example/multiple/api/v1/main.go b/example/multiple/api/v1/main.go new file mode 100644 index 0000000..4b7b47e --- /dev/null +++ b/example/multiple/api/v1/main.go @@ -0,0 +1,25 @@ +package v1 + +import ( + "github.com/gin-gonic/gin" +) + +// @title Swagger Example API +// @version 1.0 +// @description This is a sample server. +// @termsOfService http://swagger.io/terms/ + +// @contact.name API Support +// @contact.url http://www.swagger.io/support +// @contact.email support@swagger.io + +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html + +// @BasePath /v1 + +func Register(router *gin.Engine) { + v1 := router.Group("v1") + + v1.GET("/books", GetBooks) +} diff --git a/example/multiple/api/v2/example.go b/example/multiple/api/v2/example.go new file mode 100644 index 0000000..772dff1 --- /dev/null +++ b/example/multiple/api/v2/example.go @@ -0,0 +1,26 @@ +package v2 + +import ( + "github.com/gin-gonic/gin" +) + +type Book struct { + ID int `json:"id,omitempty"` + Title string `json:"title"` + Author string `json:"author"` + Year *uint16 `json:"year"` +} + +// +// @Summary Get a list of books in the the store +// @Description get string by ID +// @Accept json +// @Produce json +// @Success 200 {array} Book "ok" +// @Router /books [get] +func GetBooks(ctx *gin.Context) { + ctx.JSON(200, []Book{ + {ID: 1, Title: "Book 3", Author: "Author 3", Year: nil}, + {ID: 2, Title: "Book 4", Author: "Author 4", Year: nil}, + }) +} diff --git a/example/multiple/api/v2/main.go b/example/multiple/api/v2/main.go new file mode 100644 index 0000000..560935b --- /dev/null +++ b/example/multiple/api/v2/main.go @@ -0,0 +1,25 @@ +package v2 + +import ( + "github.com/gin-gonic/gin" +) + +// @title Swagger Example API +// @version 2.0 +// @description This is a sample server. +// @termsOfService http://swagger.io/terms/ + +// @contact.name API Support +// @contact.url http://www.swagger.io/support +// @contact.email support@swagger.io + +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html + +// @BasePath /v2 + +func Register(router *gin.Engine) { + v2 := router.Group("v2") + + v2.GET("/books", GetBooks) +} diff --git a/example/multiple/docs/v1_docs.go b/example/multiple/docs/v1_docs.go new file mode 100644 index 0000000..c18adba --- /dev/null +++ b/example/multiple/docs/v1_docs.go @@ -0,0 +1,87 @@ +// Package docs GENERATED BY SWAG; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import "github.com/swaggo/swag" + +const docTemplatev1 = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "http://www.swagger.io/support", + "email": "support@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/books": { + "get": { + "description": "get string by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get a list of books in the the store", + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.Book" + } + } + } + } + } + } + }, + "definitions": { + "v1.Book": { + "type": "object", + "properties": { + "author": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "year": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfov1 holds exported Swagger Info so clients can modify it +var SwaggerInfov1 = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "/v1", + Schemes: []string{}, + Title: "Swagger Example API", + Description: "This is a sample server.", + InfoInstanceName: "v1", + SwaggerTemplate: docTemplatev1, +} + +func init() { + swag.Register(SwaggerInfov1.InstanceName(), SwaggerInfov1) +} diff --git a/example/multiple/docs/v1_swagger.json b/example/multiple/docs/v1_swagger.json new file mode 100644 index 0000000..c68dbbc --- /dev/null +++ b/example/multiple/docs/v1_swagger.json @@ -0,0 +1,63 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server.", + "title": "Swagger Example API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "http://www.swagger.io/support", + "email": "support@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1.0" + }, + "basePath": "/v1", + "paths": { + "/books": { + "get": { + "description": "get string by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get a list of books in the the store", + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.Book" + } + } + } + } + } + } + }, + "definitions": { + "v1.Book": { + "type": "object", + "properties": { + "author": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "year": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/example/multiple/docs/v1_swagger.yaml b/example/multiple/docs/v1_swagger.yaml new file mode 100644 index 0000000..f185009 --- /dev/null +++ b/example/multiple/docs/v1_swagger.yaml @@ -0,0 +1,42 @@ +basePath: /v1 +definitions: + v1.Book: + properties: + author: + type: string + id: + type: integer + title: + type: string + year: + type: integer + type: object +info: + contact: + email: support@swagger.io + name: API Support + url: http://www.swagger.io/support + description: This is a sample server. + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + termsOfService: http://swagger.io/terms/ + title: Swagger Example API + version: "1.0" +paths: + /books: + get: + consumes: + - application/json + description: get string by ID + produces: + - application/json + responses: + "200": + description: ok + schema: + items: + $ref: '#/definitions/v1.Book' + type: array + summary: Get a list of books in the the store +swagger: "2.0" diff --git a/example/multiple/docs/v2_docs.go b/example/multiple/docs/v2_docs.go new file mode 100644 index 0000000..2c297cc --- /dev/null +++ b/example/multiple/docs/v2_docs.go @@ -0,0 +1,87 @@ +// Package docs GENERATED BY SWAG; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import "github.com/swaggo/swag" + +const docTemplatev2 = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "http://www.swagger.io/support", + "email": "support@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/books": { + "get": { + "description": "get string by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get a list of books in the the store", + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/v2.Book" + } + } + } + } + } + } + }, + "definitions": { + "v2.Book": { + "type": "object", + "properties": { + "author": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "year": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfov2 holds exported Swagger Info so clients can modify it +var SwaggerInfov2 = &swag.Spec{ + Version: "2.0", + Host: "", + BasePath: "/v2", + Schemes: []string{}, + Title: "Swagger Example API", + Description: "This is a sample server.", + InfoInstanceName: "v2", + SwaggerTemplate: docTemplatev2, +} + +func init() { + swag.Register(SwaggerInfov2.InstanceName(), SwaggerInfov2) +} diff --git a/example/multiple/docs/v2_swagger.json b/example/multiple/docs/v2_swagger.json new file mode 100644 index 0000000..495fe0d --- /dev/null +++ b/example/multiple/docs/v2_swagger.json @@ -0,0 +1,63 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server.", + "title": "Swagger Example API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "http://www.swagger.io/support", + "email": "support@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "2.0" + }, + "basePath": "/v2", + "paths": { + "/books": { + "get": { + "description": "get string by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get a list of books in the the store", + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/v2.Book" + } + } + } + } + } + } + }, + "definitions": { + "v2.Book": { + "type": "object", + "properties": { + "author": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "year": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/example/multiple/docs/v2_swagger.yaml b/example/multiple/docs/v2_swagger.yaml new file mode 100644 index 0000000..2a329e4 --- /dev/null +++ b/example/multiple/docs/v2_swagger.yaml @@ -0,0 +1,42 @@ +basePath: /v2 +definitions: + v2.Book: + properties: + author: + type: string + id: + type: integer + title: + type: string + year: + type: integer + type: object +info: + contact: + email: support@swagger.io + name: API Support + url: http://www.swagger.io/support + description: This is a sample server. + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + termsOfService: http://swagger.io/terms/ + title: Swagger Example API + version: "2.0" +paths: + /books: + get: + consumes: + - application/json + description: get string by ID + produces: + - application/json + responses: + "200": + description: ok + schema: + items: + $ref: '#/definitions/v2.Book' + type: array + summary: Get a list of books in the the store +swagger: "2.0" diff --git a/example/multiple/main.go b/example/multiple/main.go new file mode 100644 index 0000000..f362c15 --- /dev/null +++ b/example/multiple/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "github.com/gin-gonic/gin" + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" + v1 "github.com/swaggo/gin-swagger/example/multiple/api/v1" + v2 "github.com/swaggo/gin-swagger/example/multiple/api/v2" + _ "github.com/swaggo/gin-swagger/example/multiple/docs" +) + +func main() { + // New gin router + router := gin.New() + + // Register api/v1 endpoints + v1.Register(router) + router.GET("/swagger/v1/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("v1"))) + + // Register api/v2 endpoints + v2.Register(router) + router.GET("/swagger/v2/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("v2"))) + + // Listen and Server in + _ = router.Run() +} diff --git a/swagger.go b/swagger.go index f70cfa5..e918405 100644 --- a/swagger.go +++ b/swagger.go @@ -36,36 +36,36 @@ type Config struct { PersistAuthorization bool } -func (c Config) toSwaggerConfig() swaggerConfig { +func (config Config) toSwaggerConfig() swaggerConfig { return swaggerConfig{ - URL: c.URL, - DeepLinking: c.DeepLinking, - DocExpansion: c.DocExpansion, - DefaultModelsExpandDepth: c.DefaultModelsExpandDepth, + URL: config.URL, + DeepLinking: config.DeepLinking, + DocExpansion: config.DocExpansion, + DefaultModelsExpandDepth: config.DefaultModelsExpandDepth, Oauth2RedirectURL: "`${window.location.protocol}//${window.location.host}$" + "{window.location.pathname.split('/').slice(0, window.location.pathname.split('/').length - 1).join('/')}" + "/oauth2-redirect.html`", - Title: c.Title, - PersistAuthorization: c.PersistAuthorization, + Title: config.Title, + PersistAuthorization: config.PersistAuthorization, } } // URL presents the url pointing to API definition (normally swagger.json or swagger.yaml). -func URL(url string) func(c *Config) { +func URL(url string) func(*Config) { return func(c *Config) { c.URL = url } } // DocExpansion list, full, none. -func DocExpansion(docExpansion string) func(c *Config) { +func DocExpansion(docExpansion string) func(*Config) { return func(c *Config) { c.DocExpansion = docExpansion } } // DeepLinking set the swagger deep linking configuration. -func DeepLinking(deepLinking bool) func(c *Config) { +func DeepLinking(deepLinking bool) func(*Config) { return func(c *Config) { c.DeepLinking = deepLinking } @@ -73,7 +73,7 @@ func DeepLinking(deepLinking bool) func(c *Config) { // DefaultModelsExpandDepth set the default expansion depth for models // (set to -1 completely hide the models). -func DefaultModelsExpandDepth(depth int) func(c *Config) { +func DefaultModelsExpandDepth(depth int) func(*Config) { return func(c *Config) { c.DefaultModelsExpandDepth = depth } @@ -81,39 +81,40 @@ func DefaultModelsExpandDepth(depth int) func(c *Config) { // InstanceName set the instance name that was used to generate the swagger documents // Defaults to swag.Name ("swagger"). -func InstanceName(name string) func(c *Config) { +func InstanceName(name string) func(*Config) { return func(c *Config) { c.InstanceName = name } } -// PersistAuthorization If set to true, it persists authorization data and it would not be lost on browser close/refresh +// PersistAuthorization Persist authorization information over browser close/refresh. // Defaults to false. -func PersistAuthorization(persistAuthorization bool) func(c *Config) { +func PersistAuthorization(persistAuthorization bool) func(*Config) { return func(c *Config) { c.PersistAuthorization = persistAuthorization } } // WrapHandler wraps `http.Handler` into `gin.HandlerFunc`. -func WrapHandler(handler *webdav.Handler, options ...func(c *Config)) gin.HandlerFunc { - defaultConfig := Config{ +func WrapHandler(handler *webdav.Handler, options ...func(*Config)) gin.HandlerFunc { + var config = Config{ URL: "doc.json", - DeepLinking: true, DocExpansion: "list", - DefaultModelsExpandDepth: 1, InstanceName: swag.Name, Title: "Swagger UI", + DefaultModelsExpandDepth: 1, + DeepLinking: true, + PersistAuthorization: false, } for _, c := range options { - c(&defaultConfig) + c(&config) } - return CustomWrapHandler(&defaultConfig, handler) + return CustomWrapHandler(&config, handler) } -// CustomWrapHandler wraps `http.Handler` into `gin.HandlerFunc` +// CustomWrapHandler wraps `http.Handler` into `gin.HandlerFunc`. func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc { var once sync.Once @@ -126,10 +127,9 @@ func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc } // create a template with name - t := template.New("swagger_index.html") - index, _ := t.Parse(swagger_index_templ) + index, _ := template.New("swagger_index.html").Parse(swaggerIndexTpl) - var rexp = regexp.MustCompile(`(.*)(index\.html|doc\.json|favicon-16x16\.png|favicon-32x32\.png|/oauth2-redirect\.html|swagger-ui\.css|swagger-ui\.css\.map|swagger-ui\.js|swagger-ui\.js\.map|swagger-ui-bundle\.js|swagger-ui-bundle\.js\.map|swagger-ui-standalone-preset\.js|swagger-ui-standalone-preset\.js\.map)[?|.]*`) + var matcher = regexp.MustCompile(`(.*)(index\.html|doc\.json|favicon-16x16\.png|favicon-32x32\.png|/oauth2-redirect\.html|swagger-ui\.css|swagger-ui\.css\.map|swagger-ui\.js|swagger-ui\.js\.map|swagger-ui-bundle\.js|swagger-ui-bundle\.js\.map|swagger-ui-standalone-preset\.js|swagger-ui-standalone-preset\.js\.map)[?|.]*`) return func(ctx *gin.Context) { if ctx.Request.Method != http.MethodGet { @@ -138,7 +138,7 @@ func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc return } - matches := rexp.FindStringSubmatch(ctx.Request.RequestURI) + matches := matcher.FindStringSubmatch(ctx.Request.RequestURI) if len(matches) != 3 { ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound)) @@ -175,7 +175,7 @@ func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc return } - ctx.JSON(http.StatusOK, doc) + ctx.String(http.StatusOK, doc) default: handler.ServeHTTP(ctx.Writer, ctx.Request) } @@ -183,7 +183,7 @@ func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc } // DisablingWrapHandler turn handler off -// if specified environment variable passed +// if specified environment variable passed. func DisablingWrapHandler(handler *webdav.Handler, envName string) gin.HandlerFunc { if os.Getenv(envName) != "" { return func(c *gin.Context) { @@ -197,8 +197,8 @@ func DisablingWrapHandler(handler *webdav.Handler, envName string) gin.HandlerFu } // DisablingCustomWrapHandler turn handler off -// if specified environment variable passed -func DisablingCustomWrapHandler(config *Config, h *webdav.Handler, envName string) gin.HandlerFunc { +// if specified environment variable passed. +func DisablingCustomWrapHandler(config *Config, handler *webdav.Handler, envName string) gin.HandlerFunc { if os.Getenv(envName) != "" { return func(c *gin.Context) { // Simulate behavior when route unspecified and @@ -207,10 +207,10 @@ func DisablingCustomWrapHandler(config *Config, h *webdav.Handler, envName strin } } - return CustomWrapHandler(config, h) + return CustomWrapHandler(config, handler) } -const swagger_index_templ = ` +const swaggerIndexTpl = ` diff --git a/swagger_test.go b/swagger_test.go index 3d998e8..1412d6a 100644 --- a/swagger_test.go +++ b/swagger_test.go @@ -1,6 +1,7 @@ package ginSwagger import ( + "io/ioutil" "net/http" "net/http/httptest" "os" @@ -42,12 +43,18 @@ func TestWrapCustomHandler(t *testing.T) { assert.Equal(t, http.StatusInternalServerError, performRequest(http.MethodGet, "/doc.json", router).Code) - swag.Register(swag.Name, &mockedSwag{}) + doc := &mockedSwag{} + swag.Register(swag.Name, doc) w2 := performRequest(http.MethodGet, "/doc.json", router) assert.Equal(t, http.StatusOK, w2.Code) assert.Equal(t, w2.Header()["Content-Type"][0], "application/json; charset=utf-8") + // Perform body rendering validation + w2Body, err := ioutil.ReadAll(w2.Body) + assert.NoError(t, err) + assert.Equal(t, doc.ReadDoc(), string(w2Body)) + w3 := performRequest(http.MethodGet, "/favicon-16x16.png", router) assert.Equal(t, http.StatusOK, w3.Code) assert.Equal(t, w3.Header()["Content-Type"][0], "image/png") @@ -85,10 +92,10 @@ func TestDisablingWrapHandler(t *testing.T) { router.GET("/disabling/*any", DisablingWrapHandler(swaggerFiles.Handler, disablingKey)) - assert.Equal(t, 404, performRequest(http.MethodGet, "/disabling/index.html", router).Code) - assert.Equal(t, 404, performRequest(http.MethodGet, "/disabling/doc.json", router).Code) - assert.Equal(t, 404, performRequest(http.MethodGet, "/disabling/oauth2-redirect.html", router).Code) - assert.Equal(t, 404, performRequest(http.MethodGet, "/disabling/notfound", router).Code) + assert.Equal(t, http.StatusNotFound, performRequest(http.MethodGet, "/disabling/index.html", router).Code) + assert.Equal(t, http.StatusNotFound, performRequest(http.MethodGet, "/disabling/doc.json", router).Code) + assert.Equal(t, http.StatusNotFound, performRequest(http.MethodGet, "/disabling/oauth2-redirect.html", router).Code) + assert.Equal(t, http.StatusNotFound, performRequest(http.MethodGet, "/disabling/notfound", router).Code) } func TestDisablingCustomWrapHandler(t *testing.T) {