Skip to content
Snippets Groups Projects
Commit 6b94d8a0 authored by Lange, Dr. Herbert's avatar Lange, Dr. Herbert
Browse files

add font handling

parent a18b65b8
No related branches found
No related tags found
No related merge requests found
package de.uni_hamburg.corpora.server;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* @author bba1792 Dr. Herbert Lange
* @version 20220405
* Class handling font files
*/
@Path("/fonts/{staticFile}")
public class Font {
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
/**
* Method handling HTTP GET requests for font files. The returned object will be sent
* to the client
*
* @return Response containing the file or an error code
*/
@GET
public Response getStatic(@PathParam("staticFile") String fileName) {
logger.info("Loading file " + fileName);
try {
return Response.ok(this.getClass().getModule().getResourceAsStream("fonts/" + fileName).readAllBytes()).build();
}
catch (IOException e) {
return Response.status(500, "Error loading resource").build();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment