PageRenderTime 36ms CodeModel.GetById 33ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/sitebricks/src/main/java/com/google/sitebricks/http/negotiate/Accept.java

http://github.com/dhanji/sitebricks
Java | 40 lines | 10 code | 2 blank | 28 comment | 0 complexity | db3239facaf916228fc720cb0bf8f54a MD5 | raw file
 1package com.google.sitebricks.http.negotiate;
 2
 3import java.lang.annotation.ElementType;
 4import java.lang.annotation.Retention;
 5import java.lang.annotation.RetentionPolicy;
 6import java.lang.annotation.Target;
 7
 8/**
 9 * This annotation is used to select request handlers based on
10 * request headers provided by clients and can be used to perform HTTP
11 * content negotiation. If a client sends in a request for an
12 * image via uri, "/city/atlantis" and accepts JPEG type, then
13 * you may instruct sitebricks to choose a request handler as
14 * follows:
15 * <pre>
16 *   {@literal @}At("/city/atlantis")
17 *   public class PictureWebService {
18 *
19 *     {@literal @}Accept("Accept") @Get("image/jpeg")
20 *     public Response getJpeg() {
21 *       //return JPEG image...
22 *     }
23 *
24 *     {@literal @}Accept("Accept") @Get("image/png")
25 *     public Response getPng() {
26 *       //return PNG image instead...
27 *     }
28 *   }
29 * </pre>
30 *
31 *
32 * Note that you cannot mix the two kinds of negotiation.
33 *
34 * @author Dhanji R. Prasanna (dhanji@gmail.com)
35 */
36@Retention(RetentionPolicy.RUNTIME)
37@Target(ElementType.METHOD)
38public @interface Accept {
39  public abstract String value();
40}