This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pacroy.helloscp.controller; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
@RestController | |
public class HelloScpController { | |
@GetMapping("/") | |
public String hello() { | |
return "Hello SCP from Spring Boot"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pacroy.helloscp; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication | |
public class HelloScpApplication{ | |
public static void main(String ... args){ | |
SpringApplication.run(HelloScpApplication.class, args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.pacroy.helloscp</groupId> | |
<artifactId>spring-boot-helloscp</artifactId> | |
<version>1.0-SNAPSHOT</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
METHOD if_rest_resource~post. | |
DATA: BEGIN OF ls_request, | |
name TYPE char50, | |
age TYPE i, | |
city TYPE char50, | |
END OF ls_request. | |
DATA(lv_request_body) = mo_request->get_entity( )->get_string_data( ). | |
/ui2/cl_json=>deserialize( EXPORTING json = lv_request_body CHANGING data = ls_request ). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLASS zcl_complex_response DEFINITION | |
PUBLIC | |
FINAL | |
CREATE PUBLIC . | |
PUBLIC SECTION. | |
TYPES: BEGIN OF ts_phone_number, | |
type TYPE char50, | |
number TYPE char50, | |
END OF ts_phone_number, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
METHOD if_rest_application~get_root_handler. | |
DATA(lo_router) = NEW cl_rest_router( ). | |
lo_router->attach( iv_template = '/hello' iv_handler_class = 'ZCL_REST_RESOURCE' ). | |
ro_root_handler = lo_router. | |
ENDMETHOD. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
METHOD if_rest_resource~get. | |
mo_response->create_entity( )->set_string_data( `Hello world!` ). | |
ENDMETHOD. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLASS zcl_rest_resource DEFINITION | |
PUBLIC | |
INHERITING FROM cl_rest_resource | |
FINAL | |
CREATE PUBLIC . | |
PUBLIC SECTION. | |
PROTECTED SECTION. | |
PRIVATE SECTION. | |
ENDCLASS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLASS zcl_rest_handler DEFINITION | |
PUBLIC | |
INHERITING FROM cl_rest_http_handler | |
FINAL | |
CREATE PUBLIC . | |
PUBLIC SECTION. | |
METHODS: if_rest_application~get_root_handler REDEFINITION. | |
PROTECTED SECTION. | |
PRIVATE SECTION. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.*; | |
import org.junit.Test; | |
public class FizzBuzz01Test { | |
@Test | |
public void test() { | |
FizzBuzz01 fb = new FizzBuzz01(); // Arrange | |
String actual = fb.say(1); // Act |