Skip to content

fiber-server generate incorrect type for header value #1806

@turbo-nyasha

Description

@turbo-nyasha

Hi!👋🏻
Current template for fiber-server has incorrect type for header values, because HTTP Spec allow sending multiple http headers with the same name, like Set-Cookie header.

Need to change template for generate correct compiled code.

Generated code by template:

headers := c.GetReqHeaders() //map[string][]string type
...
if value, found := headers[http.CanonicalHeaderKey("x-app-version")]; found { // value has []string type
		var XAppVersion ApplicationVersion
                // value bust be string
		err = runtime.BindStyledParameterWithOptions("simple", "x-app-version", value, &XAppVersion, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: true})
		if err != nil {
			return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter x-app-version: %w", err).Error())
		}

		params.XAppVersion = XAppVersion

	} else {
		err = fmt.Errorf("Header parameter x-app-version is required, but not found: %w", err)
		return fiber.NewError(fiber.StatusBadRequest, err.Error())
	}

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