Converting the note application
Let's use the web framework to implement the note application introduced in the previous chapter.
Naming the handler functions
The handler functions become methods of a new NoteApplication
class. The HTTP method is derived from the prefix of the method name as follows:
HTTP method |
Prefixes |
---|---|
|
|
|
|
|
|
|
|
|
|
Only the GET
and POST
methods are usually used in web applications, but you should know all the prefixes in order to avoid surprises. The prefix is stripped from the name to form the route.
You can use the @path
and @method
annotations to specify a different route and HTTP method. The following is an example:
@method(HTTPMethod.GET) @path("logout") void leave() { /* ... */ }
This overrides the default POST
method with GET
and changes the URL path from...