Skip to content

Empty parameters are treated as missing #431

@mdesharnais

Description

@mdesharnais

Given the following server:

import org.jooby.*;

public class Main extends Jooby {
  {
    get("/test", req -> req.param("foo").toOptional().toString() + "\n");
  }

  public static void main(final String[] args) throws Throwable {
    run(Main::new, args);
  }
}

Empty parameters are treated as missing:

$ curl localhost:8080/test
Optional.empty
$ curl localhost:8080/test?foo
Optional.empty
$ curl localhost:8080/test?foo=
Optional.empty
$ curl localhost:8080/test?foo=abc
Optional[abc]

One sometime wants to distinguish between an absent and empty parameter. I believe the result should be:

  • Optional.empty
  • Optional[]
  • Optional[]
  • Optional[abc]

Any thought on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions