File tree Expand file tree Collapse file tree
src/main/java/io/github/devopsws/demo Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,9 +17,3 @@ You can visit it via: http://localhost:8080/graphiql?path=/graphql
1717
1818## tRPC
1919The [ tRPC] ( https://github.com/trpc-group/trpc-java ) endpoint is: ` http://localhost:9090 `
20-
21- ## OpenAPI
22- You can visit the swagger UI with the following address:
23-
24- * https://localhost:8080/swagger-ui/index.html
25- * https://localhost:8080/v3/api-docs
Original file line number Diff line number Diff line change @@ -33,6 +33,30 @@ items:
3333 Authorization : " {{ .param.auth }}"
3434 expect :
3535 body : hello
36+ - name : repeat
37+ request :
38+ api : /repeat/3
39+ query :
40+ text : a
41+ header :
42+ Authorization : " {{ .param.auth }}"
43+ expect :
44+ body :
45+ aaa
46+ - name : base64
47+ request :
48+ api : /base64
49+ method : POST
50+ body : |
51+ {
52+ "message":"OK"
53+ }
54+ header :
55+ Authorization : " {{ .param.auth }}"
56+ Content-Type : application/json
57+ expect :
58+ bodyFieldsExpect :
59+ message : T0s=
3660
3761# # Cookies
3862- name : no-cookie
Original file line number Diff line number Diff line change 33public class Message {
44 private String message ;
55
6+ // avoid the following error
7+ // JSON parse error: Cannot construct instance of
8+ public Message () {}
9+
610 public Message (String message ) {
711 this .message = message ;
812 }
Original file line number Diff line number Diff line change 11package io .github .devopsws .demo .service ;
22
3+ import java .util .Base64 ;
4+
35import org .springframework .web .bind .annotation .GetMapping ;
6+ import org .springframework .web .bind .annotation .PathVariable ;
7+ import org .springframework .web .bind .annotation .PostMapping ;
8+ import org .springframework .web .bind .annotation .RequestBody ;
49import org .springframework .web .bind .annotation .RequestParam ;
510import org .springframework .web .bind .annotation .RestController ;
11+ import io .github .devopsws .demo .model .Message ;
612
713@ RestController
814public class StringService {
915 @ GetMapping ("/lower" )
10- public String lower (@ RequestParam (required = true ) String text ) {
16+ public String lower (@ RequestParam (required = true ) String text ,
17+ @ RequestParam (required = false ) boolean trim ) {
18+ if (trim ) {
19+ text =text .trim ();
20+ }
1121 return text .toLowerCase ();
1222 }
23+
24+ @ GetMapping ("/repeat/{count}" )
25+ public String repeat (@ RequestParam (required = true ) String text ,
26+ @ PathVariable int count ) {
27+ return text .repeat (count );
28+ }
29+
30+ @ PostMapping ("/base64" )
31+ public Message base64 (@ RequestBody Message message ) {
32+ String encodedString = Base64 .getEncoder ().encodeToString (message .getMessage ().getBytes ());
33+ message .setMessage (encodedString );
34+ return message ;
35+ }
1336}
You can’t perform that action at this time.
0 commit comments