11package io .dinject .javalin .generator ;
22
33import io .dinject .controller .Delete ;
4+ import io .dinject .controller .Form ;
45import io .dinject .controller .Get ;
56import io .dinject .controller .Patch ;
67import io .dinject .controller .Post ;
@@ -27,6 +28,8 @@ class MethodReader {
2728 private WebMethod webMethod ;
2829 private String webMethodPath ;
2930
31+ private boolean formMarker ;
32+
3033 /**
3134 * Holds enum Roles that are required for the method.
3235 */
@@ -39,6 +42,8 @@ class MethodReader {
3942 this .element = element ;
4043 this .isVoid = element .getReturnType ().toString ().equals ("void" );
4144 this .methodRoles = Util .findRoles (element );
45+
46+ readMethodAnnotation ();
4247 }
4348
4449 void read () {
@@ -49,17 +54,19 @@ void read() {
4954 }
5055 }
5156
57+ // non-path parameters default to form or query parameters based on the
58+ // existence of @Form annotation on the method
59+ ParamType defaultParamType = (formMarker ) ? ParamType .FORMPARAM : ParamType .QUERYPARAM ;
60+
5261 for (VariableElement p : element .getParameters ()) {
53- MethodParam param = new MethodParam (p , ctx );
62+ MethodParam param = new MethodParam (p , ctx , defaultParamType );
5463 params .add (param );
5564 param .addImports (bean );
5665 }
5766 }
5867
5968 void addRoute (Append writer ) {
6069
61- readMethodAnnotation ();
62-
6370 if (webMethod != null ) {
6471
6572 String fullPath = Util .combinePath (beanPath , webMethodPath );
@@ -122,6 +129,11 @@ private boolean isReturnJson() {
122129
123130 private boolean readMethodAnnotation () {
124131
132+ Form form = element .getAnnotation (Form .class );
133+ if (form != null ) {
134+ this .formMarker = true ;
135+ }
136+
125137 Get get = element .getAnnotation (Get .class );
126138 if (get != null ) {
127139 return setWebMethod (WebMethod .GET , get .value ());
0 commit comments