/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

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