Skip to content

Alternate HTTPObjects creation API #15

@ratamacue

Description

@ratamacue

Instead of extending HTTPObject, I would like to delegate to it. One way to achieve that is to create factory classes that generate HTTPObjects rather than classes that extend HTTPObject.

Instead of:

HttpObject speaker = new HttpObject("/speak"){
            @Override
            public Response get(Request req) {
                return OK(Html("Hello World"));
            }
        };

Something like:

HttpObject speaker = new HttpObject("/speak", Get(req->OK(Html("Hello World"))));

The Method Signature of the HttpObject constructor could take a vararg of handlers (with a check to ensure no duplicate verbs are used) such as

public HttpObject(String path, HttpVerbs... handlers)

Would anybody on this project object to me adding this interface to HTTPObjects?

Metadata

Metadata

Assignees

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