Write logic for createElection validation
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
// Package api provides primitives to interact with the openapi HTTP API.
|
||||
//
|
||||
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
|
||||
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.2.0 DO NOT EDIT.
|
||||
package api
|
||||
|
||||
import (
|
||||
@ -26,7 +26,7 @@ type CreateElectionRequest struct {
|
||||
// ErrorResponse defines model for ErrorResponse.
|
||||
type ErrorResponse struct {
|
||||
// Code Machine-readable error code
|
||||
Code string `json:"code"`
|
||||
Code int `json:"code"`
|
||||
|
||||
// Details Additional error details when available
|
||||
Details *map[string]interface{} `json:"details"`
|
||||
@ -56,6 +56,7 @@ type MiddlewareFunc func(http.Handler) http.Handler
|
||||
|
||||
// CreateElection operation middleware
|
||||
func (siw *ServerInterfaceWrapper) CreateElection(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.CreateElection(w, r)
|
||||
@ -65,7 +66,7 @@ func (siw *ServerInterfaceWrapper) CreateElection(w http.ResponseWriter, r *http
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
handler.ServeHTTP(w, r.WithContext(ctx))
|
||||
}
|
||||
|
||||
type UnescapedCookieParamError struct {
|
||||
@ -142,27 +143,21 @@ func Handler(si ServerInterface) http.Handler {
|
||||
return HandlerWithOptions(si, StdHTTPServerOptions{})
|
||||
}
|
||||
|
||||
// ServeMux is an abstraction of http.ServeMux.
|
||||
type ServeMux interface {
|
||||
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
|
||||
ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
type StdHTTPServerOptions struct {
|
||||
BaseURL string
|
||||
BaseRouter ServeMux
|
||||
BaseRouter *http.ServeMux
|
||||
Middlewares []MiddlewareFunc
|
||||
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
|
||||
}
|
||||
|
||||
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
|
||||
func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler {
|
||||
func HandlerFromMux(si ServerInterface, m *http.ServeMux) http.Handler {
|
||||
return HandlerWithOptions(si, StdHTTPServerOptions{
|
||||
BaseRouter: m,
|
||||
})
|
||||
}
|
||||
|
||||
func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler {
|
||||
func HandlerFromMuxWithBaseURL(si ServerInterface, m *http.ServeMux, baseURL string) http.Handler {
|
||||
return HandlerWithOptions(si, StdHTTPServerOptions{
|
||||
BaseURL: baseURL,
|
||||
BaseRouter: m,
|
||||
|
Reference in New Issue
Block a user