-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecates the StructuredService framework and provides a replacement using plain Controllers. #855
Conversation
Using the annotations @publicservice or @InternalService, one can define that a route is considered a service call with a certain response format. Previously this was done using Routed.jsonCall. We now use extra annotations to support XML as additional format. Using @publicservice also provides the benefit of self-documentation as these services are listed in the Public API explorer.
If the response is already committed, we do not need to care about the HTTP code, we simply have to submit an error so that the underlying channel is closed. Also, if the response for a service call was already commited as the internal buffer is full, we can no longer report and error. This (edge) case is now logged at least to support debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build fails
*/ | ||
public List<PublicApiInfo> getApis() { | ||
synchronized (apis) { | ||
return new ArrayList<>(apis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unmodifiableList?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to copy because of threading issues - the copy doesn't need to be unmodifyable as it is unused elsewhere..
if (apiInfo == null) { | ||
apiInfo = buildApiInfo(publicService.apiName(), route); | ||
apis.add(apiInfo); | ||
apis.sort(Comparator.comparing(PublicApiInfo::getPriority).thenComparing(PublicApiInfo::getApiName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd make apis
a TreeSet
it takes care of the order by itself, but it's fine like that as well
Watch w = Watch.start(); | ||
|
||
CommandParser parser = new CommandParser(webContext.require("command").asString()); | ||
if (Strings.isEmpty(parser.parseCommand())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parse once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse command is a noop the 2nd and 3rd call...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build seems to fail because of the WebServerSpec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 typos found
Co-authored-by: Matthias Keck <60612914+mkeckmkeck@users.noreply.github.com>
Co-authored-by: Matthias Keck <60612914+mkeckmkeck@users.noreply.github.com>
This contains some internal breaking changes as i.e. the API of Intereptor has changed.
Public API Explorer
Also, we now detect and show all recognized public APIs:
Migrating Services
Migrating from StructuredService(s) to the new API is as simple as moving the call(..) method into a Controller and replacing the ServiceCall parameter by WebContext and the StructuredOutput by either JSONStructuredOutput or XMLStructuredOutput (depending on the format). Finally either a @InternalService or @publicservice annotation has to be added to the method.