Skip to content

REST: Status Codes #668

@davewhit3

Description

@davewhit3

Describe the bug
I don't have option to set response code. [source code]
In REST with a POST method and a status code of 201 I could send a location header, but it could be 200, 202 or 204.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201

The code is

 if err == nil {
 	switch r.method {
 	case http.MethodPost:
 		return http.StatusCreated, nil
 	case http.MethodDelete:
 		return http.StatusNoContent, nil
 	default:
 		return http.StatusOK, nil
 	}
 }

Expected behavior
I can set the response code and headers.

Environments (please complete the following information):

  • OS: Linux
  • gofr version v1.6.1
  • go version 1.22

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