All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.holonplatform.jaxrs.examples.ExampleRequest Maven / Gradle / Ivy

There is a newer version: 5.7.0
Show newest version
/*
 * Copyright 2016-2017 Axioma srl.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.holonplatform.jaxrs.examples;

import java.util.Locale;
import java.util.Optional;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import com.holonplatform.jaxrs.server.JaxrsHttpRequest;

@SuppressWarnings("unused")
public class ExampleRequest {

	// tag::jaxrsreq[]
	@GET
	@Path("name")
	@Produces(MediaType.TEXT_PLAIN)
	public String ping(@Context Request request, @Context UriInfo uriInfo, @Context HttpHeaders headers) {

		JaxrsHttpRequest req = JaxrsHttpRequest.create(request, uriInfo, headers); // <1>

		Optional locale = req.getLocale(); // <2>

		return "pong";
	}
	// end::jaxrsreq[]

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy