This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiController.cs
More file actions
60 lines (47 loc) · 2.12 KB
/
ApiController.cs
File metadata and controls
60 lines (47 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using ApiFrontend.Models;
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace ApiFrontend.Controllers
{
public class ApiController : Controller
{
//INDEX
private static HttpClient httpClient = new HttpClient();
public ApiController(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// CoinStat
[HttpGet]
public async Task<IActionResult> CoinStat_All()
{
// httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));
var response = await httpClient.GetAsync(Configuration.GetValue<string>("coinstat"));
var content = await response.Content.ReadAsStringAsync();
var Api = new List<Api>();
// if (response.Content.Headers.ContentType.MediaType == "application/json")
// {
Api = JsonConvert.DeserializeObject<List<Api>>(content);
// }
return View(Api);
}
// CoinLore
[HttpGet]
public async Task<IActionResult> CoinLore_Individual()
{
// httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));
var response = await httpClient.GetAsync(Configuration.GetValue<string>("coinlore"));
var content = await response.Content.ReadAsStringAsync();
var Api = new List<Api>();
// if (response.Content.Headers.ContentType.MediaType == "application/json")
// {
Api = JsonConvert.DeserializeObject<List<Api>>(content);
// }
return View(Api);
}
}
}