jax-rs-spec
  1. jax-rs-spec
  2. JAX_RS_SPEC-18

@HttpMethod should guess value if omitted

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: ice box
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      88

      Description

      Typically, JAX-RS methods are defined by a 1:1 relation between the
      annotation's (@interface's) name, and the same name provided in the @HttpMethod
      value:

      @HttpMethod("FOOBAR")
      public @interface FOOBAR {
      }

      As it is rather tedious and error-prone to always repeat the same string twice,
      it would be a nice feature if by default the @HttpMethod would expect this name
      equalness if the value attribute was left out:

      @HttpMethod // implies value="FOOBAR" by default
      public @interface FOOBAR {
      }

      The reduces the possibility of typos (unintentional deviation of @HttpMethod's
      value and annotation's interface name) and is less boring.

      As this is not a major feature but just a slight improvement, and as this is
      does not break the binary backwards compatibility, I want to propose the
      adoption of this minor feature into JSR311 Maintenance Release 1.2.

        Issue Links

          Activity

          Hide
          mkarg added a comment -

          I'd like to discuss the following, optional addition to the above proposal:

          In case the annotation's (@interface's) name contains an underscore character
          ('_'), each occurence of this character shall get replaced by a hyphen
          character ('-') in the default value of the @HttpMethod annotation:

          @HttpMethod // implied value="FOO-BAR" due to default behaviour
          public @interface FOO_BAR {
          }

          The reason is that it is more typical in HTTP names to use hyphens instead of
          underscores. For example, WebDAV is using underscores in several HTTP method
          names like "VERSION-CONTROL". It makes sense to follow the "convention over
          configuration" pattern and support the convention of hyphens in HTTP instead of
          forcing explicit configuration.

          Show
          mkarg added a comment - I'd like to discuss the following, optional addition to the above proposal: In case the annotation's (@interface's) name contains an underscore character ('_'), each occurence of this character shall get replaced by a hyphen character ('-') in the default value of the @HttpMethod annotation: @HttpMethod // implied value="FOO-BAR" due to default behaviour public @interface FOO_BAR { } The reason is that it is more typical in HTTP names to use hyphens instead of underscores. For example, WebDAV is using underscores in several HTTP method names like "VERSION-CONTROL". It makes sense to follow the "convention over configuration" pattern and support the convention of hyphens in HTTP instead of forcing explicit configuration.
          Hide
          Marek Potociar added a comment -

          Deferring to future release.

          Show
          Marek Potociar added a comment - Deferring to future release.

            People

            • Assignee:
              Unassigned
              Reporter:
              mkarg
            • Votes:
              2 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: