Skip to content

HttpMaid directly publishes your business logic as an HTTP endpoint.

License

Notifications You must be signed in to change notification settings

quantummaid/httpmaid

CII Best Practices Maintainability Rating Reliability Rating Security Rating Quality Gate Status Technical Debt Bugs Code Smells Coverage Last Commit Maven Central Code Size License Slack Gitter Twitter

HttpMaid

HttpMaid directly publishes your business logic as an HTTP endpoint. It's non-invasive, secure and flexible.

Let's see an example:

final HttpMaid httpMaid = HttpMaid.anHttpMaid()
        .get("/api/hello", (request, response) -> {
            httpResponse.setBody("Hello World!");
            httpResponse.setStatus(200);
        })
        .build();

Once your usecase is more complicated than just saying hello, you want to focus on implementing it instead of dealing with protocol details.

Let's say we have the usecase of sending an email:

public class SendEmail {

    public Receipt sendEmail(final Email email) {
        final String trackingId = send(email.sender, email.receiver, email.subject, email.body);
        final String timestamp = String.valueOf(Instant.now().toEpochMilli());

        return new Receipt(trackingId, timestamp);
    }
}

Now we can expose this usecase using HttpMaid:

final HttpMaid httpMaid = HttpMaid.anHttpMaid()
        .post("/api/sendEmail", SendEmail.class)
        .build();

It's that simple - and stays that simple, even when things get more complicated. Look here for a complete tutorial.

What is HttpMaid doing for you?

Good architecture is less about the decisions you make and more about the decisions you defer making.

HttpMaid allows you to write your usecases decoupled from the underlying hazards of an HTTP/REST infrastructure. Stop debating tiresome questions like:

  • "Should it be a PUT or a POST?"
  • "Is the username coming from the request body, the JWT token or a plain text header value?"
  • "Are we talking Json, YAML, XML or a custom (binary?) content type?"

You can't possibly know the answer until you've faced the customer. And then she might just change her mind.

Other features

Besides allowing you to easily export usecases, HttpMaid offers the following features:

  • seamless endpoint integrations such as
    • AWS Lambda
    • Jetty
    • Servlet
  • authentication and authorization using JWT
  • predefined CORS configurations
  • multipart request handling

Why another HTTP framework?

The goal of refactoring is to actively counteract the natural increase in the degree of chaos.

We did not find any framework that would allow us to develop a web application and claim in good conscience that our business logic does not depend on the underlying HTTP server, persistence layer or (de-)serialization mechanism (also referred to as infrastructure code in Domain-Driven Design).

Getting started

HttpMaid is part of the QuantumMaid framework. You can find easy-to-follow and interesting tutorials here.

The HttpMaid documentation can be found here.

Get in touch

Feel free to join us on Slack or Gitter to ask questions, give feedback or just discuss software architecture with the team behind HttpMaid. Also, don't forget to visit our website and follow us on Twitter!

About

HttpMaid directly publishes your business logic as an HTTP endpoint.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages