martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
405 stars 23 forks source link

Add support for specifying HTTP response status codes using symbols #120

Closed ellmetha closed 11 months ago

ellmetha commented 1 year ago

Description

Presently, the only way to specify status codes in the various handler helpers that return HTTP responses (such as #respond, #render, #json, or #head) is to specify the raw status code value, expressed as an integer. It would be convenient to be able to specify those response status codes using Rails-esque symbols (with which a lot of developers are used to).

For example, it would be possible to do things like:

class MyHandler < Marten::Handler
  def get
    respond "It does not work", status: :bad_request)
  end
end

Let's add support for specifying such status code symbols as part of the following handler helper methods:

ellmetha commented 11 months ago

Fixed by #124.