HandlerWithOptions creates http.Handler with additional options
(si ServerInterface, options GorillaServerOptions)
| 149 | |
| 150 | // HandlerWithOptions creates http.Handler with additional options |
| 151 | func HandlerWithOptions(si ServerInterface, options GorillaServerOptions) http.Handler { |
| 152 | r := options.BaseRouter |
| 153 | |
| 154 | if r == nil { |
| 155 | r = mux.NewRouter() |
| 156 | } |
| 157 | if options.ErrorHandlerFunc == nil { |
| 158 | options.ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) { |
| 159 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 160 | } |
| 161 | } |
| 162 | wrapper := ServerInterfaceWrapper{ |
| 163 | Handler: si, |
| 164 | HandlerMiddlewares: options.Middlewares, |
| 165 | ErrorHandlerFunc: options.ErrorHandlerFunc, |
| 166 | } |
| 167 | |
| 168 | r.HandleFunc(options.BaseURL+"/ping", wrapper.GetPing).Methods(http.MethodGet) |
| 169 | |
| 170 | return r |
| 171 | } |
| 172 | |
| 173 | // Base64 encoded, compressed with deflate, json marshaled OpenAPI spec. |
| 174 | // Stored as a slice of fixed-width chunks rather than one concatenated |
no test coverage detected