Skip to content

Commit

Permalink
Merge pull request #401 from yggdrash/feature/crossDomain
Browse files Browse the repository at this point in the history
Add Cross Domain patch
  • Loading branch information
Peter Ryu committed Oct 29, 2019
2 parents 99961ba + 8a181c5 commit 302b83f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -35,6 +36,7 @@
import static io.yggdrash.common.config.Constants.BRANCH_ID;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("branches/{branchId}/blocks")
class BlockController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.yggdrash.gateway.dto.BranchDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -30,6 +31,7 @@
import java.util.Map;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("branches")
public class BranchController {
private final BranchGroup branchGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -19,6 +20,7 @@
import java.util.List;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("contract")
public class ContractController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.yggdrash.core.blockchain.BranchId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -25,6 +26,7 @@
import static io.yggdrash.common.config.Constants.BRANCH_ID;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("branches/{branchId}/logs")
public class LogController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.yggdrash.core.p2p.PeerTableGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -30,6 +31,7 @@
import static io.yggdrash.common.config.Constants.BRANCH_ID;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("peers")
class PeerController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -40,6 +41,7 @@
import static io.yggdrash.common.config.Constants.BRANCH_ID;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("branches/{branchId}/txs")
class TransactionController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.yggdrash.gateway.dto.TransactionReceiptDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -26,6 +27,7 @@
import static io.yggdrash.common.config.Constants.BRANCH_ID;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("branches/{branchId}/txr")
public class TransactionReceiptController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Profile(Constants.ActiveProfiles.NODE)
@Configuration
Expand All @@ -30,5 +32,18 @@ public class JsonRpcConfiguration {
public AutoJsonRpcServiceImplExporter autoJsonRpcServiceImplExporter() {
return new AutoJsonRpcServiceImplExporter();
}

@Bean
public WebMvcConfigurer webMvcConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedHeaders("*")
.allowedMethods("*")
.allowedOrigins("*");
}
};
}
}

0 comments on commit 302b83f

Please sign in to comment.