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

com.google.sitebricks.http.negotiate.Accept Maven / Gradle / Ivy

The newest version!
package com.google.sitebricks.http.negotiate;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This annotation is used to select request handlers based on
 * request headers provided by clients and can be used to perform HTTP
 * content negotiation. If a client sends in a request for an
 * image via uri, "/city/atlantis" and accepts JPEG type, then
 * you may instruct sitebricks to choose a request handler as
 * follows:
 * 
 *   {@literal @}At("/city/atlantis")
 *   public class PictureWebService {
 *
 *     {@literal @}Accept("Accept") @Get("image/jpeg")
 *     public Response getJpeg() {
 *       //return JPEG image...
 *     }
 *
 *     {@literal @}Accept("Accept") @Get("image/png")
 *     public Response getPng() {
 *       //return PNG image instead...
 *     }
 *   }
 * 
* * * Note that you cannot mix the two kinds of negotiation. * * @author Dhanji R. Prasanna ([email protected]) */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Accept { public abstract String value(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy