简体   繁体   中英

Custom HTTP status codes from AppEngine Java endpoints

Everyone loves REST-fulness, so I'd like to return the most appropriate HTTP status codes from my AppEngine endpoints. Like 201 CREATED, for example, when a resource has been created.

But I can't find how to do this with GAE Java endpoints.

Some 4xx codes are supported by throwing an exception (NotFoundException causes a 404, for example), but that's not an appropriate solution for 2xx codes.

Can anyone help please?

Matthew

Cloud Endpoints does support creating your own Custom Exception classes by subclassing com.google.api.server.spi.ServiceException

However, from the documentation at https://developers.google.com/appengine/docs/java/endpoints/exceptions , it is mentioned that HTTP 2xx codes should not be used in custom exception classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM