package dev.dinauer.maven.maven.core.rest;

import com.fasterxml.jackson.core.JsonProcessingException;
import dev.dinauer.maven.maven.core.MavenService;
import dev.dinauer.maven.maven.core.release.ReleaseService;
import io.quarkus.security.Authenticated;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;


@Path("/maven2")
@Authenticated
public class Resource
{
    @Inject
    ReleaseService releaseService;

    @Inject
    MavenService mavenService;

    @PUT
    @Path("/{path: .*}")
    public void put(@PathParam("path") String path, byte[] body) throws JsonProcessingException
    {
        mavenService.upload(path, body);
    }

    @GET
    @Path("/{path: .*}")
    public Response get(@PathParam("path") String path) throws JsonProcessingException
    {
        return mavenService.serve(path);
    }
}
