com.artipie.nuget.http.SliceFromResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nuget-adapter Show documentation
Show all versions of nuget-adapter Show documentation
Turns your files/objects into NuGet artifacts
/*
* The MIT License (MIT) Copyright (c) 2020-2023 artipie.com
* https://github.com/artipie/artipie/blob/master/LICENSE.txt
*/
package com.artipie.nuget.http;
import com.artipie.asto.Content;
import com.artipie.http.Headers;
import com.artipie.http.Response;
import com.artipie.http.Slice;
import com.artipie.http.rq.RequestLine;
import com.artipie.http.rq.RqMethod;
import com.artipie.http.ResponseBuilder;
import java.util.concurrent.CompletableFuture;
/**
* Slice created from {@link Resource}.
*/
final class SliceFromResource implements Slice {
/**
* Origin resource.
*/
private final Resource origin;
/**
* @param origin Origin resource.
*/
SliceFromResource(final Resource origin) {
this.origin = origin;
}
@Override
public CompletableFuture response(RequestLine line, Headers headers, Content body) {
final RqMethod method = line.method();
if (method.equals(RqMethod.GET)) {
return this.origin.get(headers);
}
if (method.equals(RqMethod.PUT)) {
return this.origin.put(headers, body);
}
return ResponseBuilder.methodNotAllowed().completedFuture();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy