Newer
Older
CosmosServer / src / main / java / com / example / cosmos_serversb / resources / UsersRest.java
t-kisimoto on 14 May 2019 681 bytes initial
package com.example.cosmos_serversb.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonProcessingException;

class Info {
    public String name;
    public String email;
}

@Component
@Path("/users")
public class UsersRest {
    @GET
    public String index() throws JsonProcessingException {
        Info info = new Info();
        info.name = "tiger";
        info.email = "tiger@gmail.com";
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(info);

        return json;
    }

}