Package com.renomad.minum.web


package com.renomad.minum.web
Code and data for HTTP web serving.

Here is a typical "main" method for an application. The important thing to note is we are initializing FullSystem and using it to register endpoints. A more organized approach is to put the endpoint registrations into another file. See the example project in the Minum codebase or any of the other example projects.

 
 package org.example;

 import com.renomad.minum.web.FullSystem;
 import com.renomad.minum.web.Response;

 import static com.renomad.minum.web.RequestLine.Method.GET;

 public class Main {

     public static void main(String[] args) {
         FullSystem fs = FullSystem.initialize();
         fs.getWebFramework().registerPath(GET, "", request -> Response.htmlOk("<p>Hi there world!</p>"));
         fs.block();
     }
 }
 
 

Here's an example of a business-related function using authentication and the Minum database. This code is extracted from the SampleDomain.java file in the src/test directory:


       public IResponse formEntry(IRequest r) {
         final var authResult = auth.processAuth(r);
         if (! authResult.isAuthenticated()) {
             return Response.buildLeanResponse(CODE_401_UNAUTHORIZED);
         }
         final String names = db
                 .values().stream().sorted(Comparator.comparingLong(PersonName::getIndex))
                 .map(x -> "<li>" + StringUtils.safeHtml(x.getFullname()) + "</li>\n")
                 .collect(Collectors.joining());

         return Response.htmlOk(nameEntryTemplate.renderTemplate(Map.of("names", names)));
     }
     
  
  • Class
    Description
    This class represents the body of an HTML message.
    The type of HTTP request body
    This class represents the information in the Content-Disposition header of a multipart/form-data partition.
    This class is responsible for instantiating necessary classes for a valid system, in the proper order.
    Tools to enable system-wide integration testing
    A Response designed to work with FunctionalTesting
    Details extracted from the headers.
    An enum to represent the mode of conversation for HTTP - plain text or encrypted (TLS)
    The HTTP versions we handle
    An interface for the BodyProcessor implementation.
    This exception is thrown if the range of bytes provided for a request is improper - such as if the range values were negative, wrongly-ordered, and so on.
    An interface for Request.
    An interface for Response.
    An interface for the Server implementation.
    This is the public interface to ISocketWrapper, whose purpose is to make our lives easier when working with Socket.
    The parameters required to set up a handler that is run after everything else in the web framework.
    Represents a single partition in a multipart/form-data body response
    Some essential characteristics of the path portion of the start line
    The input parameters that are required to add a pre-handler.
    An HTTP request.
    This class holds data and methods for dealing with the "start line" in an HTTP request.
    These are the HTTP methods we handle.
    Represents an HTTP response.
    This class represents the text that is sent back in a Response
    This class represents a single partition in a multipart/form Request body, when read as an InputStream.
    This exists so that we are able to better manage exceptions in a highly threaded system.
    This exists so that we are able to better manage exceptions in a highly threaded system.
    This class enables pulling key-value pairs one at a time from the Request body.
    Represents a key-value pair with URL-encoding.
    This class is responsible for the HTTP handling after socket connection.
    This is just a RuntimeException that is scoped for our web server.