Skip to content

bowbahdoe/microhttp-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microhttp-json

Utility for producing JSON responses in microhttp

Dependency Information

Maven

<dependency>
    <groupId>dev.mccue</groupId>
    <artiactId>microhttp-json</artiactId>
    <version>0.0.1</version>
</dependency>

Gradle

dependencies {
    implementation('dev.mccue:microhttp-json:0.0.1')
}

Usage

import dev.mccue.json.Json;
import dev.mccue.microhttp.handler.IntoResponse;
import dev.mccue.microhttp.handler.RouteHandler;
import dev.mccue.microhttp.json.JsonResponse;
import org.jspecify.annotations.Nullable;
import org.microhttp.Request;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SomeHandler extends RouteHandler {
    public SomeHandler() {
        super("GET", Pattern.compile("/some/path"));
    }

    @Override
    protected IntoResponse handleRoute(Matcher matcher, Request request) {
        return new JsonResponse(Json.objectBuilder()
                .put("name", "victor")
                .put("rodger", true)
                .build()
        );
    }
}

About

Utility for producing JSON responses in microhttp

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages