This repository has been archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add orderbook endpint to rest api add banner for rest api
- Loading branch information
Valentin Stavetski
committed
Apr 28, 2018
1 parent
9700c0a
commit e6bd740
Showing
9 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
12 changes: 12 additions & 0 deletions
12
rest-api/src/main/kotlin/fund/cyber/markets/api/rest/configuration/RestApiConfiguration.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package fund.cyber.markets.api.rest.configuration | ||
|
||
import fund.cyber.markets.common.EXCHANGES_CONNECTOR_SERVICE_URL | ||
import fund.cyber.markets.common.EXCHANGES_CONNECTOR_SERVICE_URL_DEFAULT | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class RestApiConfiguration( | ||
@Value("\${$EXCHANGES_CONNECTOR_SERVICE_URL:$EXCHANGES_CONNECTOR_SERVICE_URL_DEFAULT}") | ||
val exchangesConnectorServiceUrl: String | ||
) |
48 changes: 48 additions & 0 deletions
48
rest-api/src/main/kotlin/fund/cyber/markets/api/rest/controller/RawDataController.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package fund.cyber.markets.api.rest.controller | ||
|
||
import fund.cyber.markets.api.rest.configuration.RestApiConfiguration | ||
import fund.cyber.markets.common.model.OrderBook | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.springframework.web.client.HttpClientErrorException | ||
import org.springframework.web.client.RestTemplate | ||
import org.springframework.web.util.UriComponentsBuilder | ||
import reactor.core.publisher.Mono | ||
|
||
|
||
const val ORDERBOOK_PATH = "/orderbook" | ||
|
||
@RestController | ||
class RawDataController { | ||
|
||
@Autowired | ||
private lateinit var configuration: RestApiConfiguration | ||
|
||
private val restTemplate = RestTemplate() | ||
|
||
@GetMapping("/orderbook") | ||
fun getOrderBook( | ||
@RequestParam exchange: String, | ||
@RequestParam pair: String, | ||
@RequestParam(required = false) ts: Long? | ||
): Mono<OrderBook> { | ||
|
||
val requestUri = configuration.exchangesConnectorServiceUrl + ORDERBOOK_PATH | ||
|
||
val builder = UriComponentsBuilder.fromUriString(requestUri) | ||
.queryParam("exchange", exchange) | ||
.queryParam("pair", pair) | ||
|
||
var response: OrderBook? = null | ||
try { | ||
response = restTemplate.getForObject<OrderBook>(builder.toUriString(), OrderBook::class.java) | ||
} catch (e: HttpClientErrorException) { | ||
|
||
} | ||
|
||
return Mono.just(response!!) | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server: | ||
port: 8085 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
_____ _____ _____ _____ _____ _____ _____ | ||
/\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /\ \ | ||
/::\ \ /::\ \ /::\ \ /::\ \ /::\ \ /::\ \ /::\ \ | ||
/::::\ \ /::::\ \ /::::\ \ \:::\ \ /::::\ \ /::::\ \ \:::\ \ | ||
/::::::\ \ /::::::\ \ /::::::\ \ \:::\ \ /::::::\ \ /::::::\ \ \:::\ \ | ||
/:::/\:::\ \ /:::/\:::\ \ /:::/\:::\ \ \:::\ \ /:::/\:::\ \ /:::/\:::\ \ \:::\ \ | ||
/:::/__\:::\ \ /:::/__\:::\ \ /:::/__\:::\ \ \:::\ \ /:::/__\:::\ \ /:::/__\:::\ \ \:::\ \ | ||
/::::\ \:::\ \ /::::\ \:::\ \ \:::\ \:::\ \ /::::\ \ /::::\ \:::\ \ /::::\ \:::\ \ /::::\ \ | ||
/::::::\ \:::\ \ /::::::\ \:::\ \ ___\:::\ \:::\ \ /::::::\ \ /::::::\ \:::\ \ /::::::\ \:::\ \ ____ /::::::\ \ | ||
/:::/\:::\ \:::\____\ /:::/\:::\ \:::\ \ /\ \:::\ \:::\ \ /:::/\:::\ \ /:::/\:::\ \:::\ \ /:::/\:::\ \:::\____\ /\ \ /:::/\:::\ \ | ||
/:::/ \:::\ \:::| |/:::/__\:::\ \:::\____\/::\ \:::\ \:::\____\ /:::/ \:::\____\ /:::/ \:::\ \:::\____\/:::/ \:::\ \:::| |/::\ \/:::/ \:::\____\ | ||
\::/ |::::\ /:::|____|\:::\ \:::\ \::/ /\:::\ \:::\ \::/ / /:::/ \::/ / \::/ \:::\ /:::/ /\::/ \:::\ /:::|____|\:::\ /:::/ \::/ / | ||
\/____|:::::\/:::/ / \:::\ \:::\ \/____/ \:::\ \:::\ \/____/ /:::/ / \/____/ \/____/ \:::\/:::/ / \/_____/\:::\/:::/ / \:::\/:::/ / \/____/ | ||
|:::::::::/ / \:::\ \:::\ \ \:::\ \:::\ \ /:::/ / \::::::/ / \::::::/ / \::::::/ / | ||
|::|\::::/ / \:::\ \:::\____\ \:::\ \:::\____\ /:::/ / \::::/ / \::::/ / \::::/____/ | ||
|::| \::/____/ \:::\ \::/ / \:::\ /:::/ / \::/ / /:::/ / \::/____/ \:::\ \ | ||
|::| ~| \:::\ \/____/ \:::\/:::/ / \/____/ /:::/ / ~~ \:::\ \ | ||
|::| | \:::\ \ \::::::/ / /:::/ / \:::\ \ | ||
\::| | \:::\____\ \::::/ / /:::/ / \:::\____\ | ||
\:| | \::/ / \::/ / \::/ / \::/ / | ||
\|___| \/____/ \/____/ \/____/ \/____/ |