Skip to content

Move StrictHTTPServerOptions to strictnethttp package #2224

@jay-babu

Description

@jay-babu

The problem is that when splitting the generation of the spec (based on tags) across multiple configuration files and using the strict-server: true, it outputs

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

Unsure if there is a reason for this to be specified per generated server code, but if this was moved to strictnethttp package or something else, I would not have to implement the same piece of code multiple times.

StrictMiddlewareFunc and StrictHandlerFunc do this hence the ask here.

	edmStrict := edm.NewStrictHandlerWithOptions(s, strictMiddlewares, edm.StrictHTTPServerOptions{
		RequestErrorHandlerFunc:  httpproblem.RequestErrorHandler(s.logger),
		ResponseErrorHandlerFunc: httpproblem.ResponseErrorHandler(s.logger),
	})
	icStrict := ic.NewStrictHandlerWithOptions(s, strictMiddlewares, ic.StrictHTTPServerOptions{
		RequestErrorHandlerFunc:  httpproblem.RequestErrorHandler(s.logger),
		ResponseErrorHandlerFunc: httpproblem.ResponseErrorHandler(s.logger),
	})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions