You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.7 KiB
C#

9 months ago
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using ZKLT.Hadoop;
namespace ZKLT.Hadoop.API
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
#region Cors<72><73><EFBFBD><EFBFBD>
builder.Services.AddCors(options =>
{
options.AddPolicy("all", builder =>
{
builder.SetIsOriginAllowed(origin => true) //<2F><><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cookie
});
});
#endregion
9 months ago
// Add services to the container.
builder.Services.AddControllers().AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHadoop();
var app = builder.Build();
#region Cors<72><73><EFBFBD><EFBFBD>
app.UseCors("all");
#endregion
//app.UseHadoop((c) =>
//{
// c.Host = "127.0.0.1";
// c.Account = "root";
// c.PassWord = "root";
// c.Key = "hadoopdb";
// c.Port = 3306;
//});
app.UseHadoop((c) =>
{
c.Host = app.Configuration["ConnectionStrings:Host"];
c.Account = app.Configuration["ConnectionStrings:Account"];
c.PassWord = app.Configuration["ConnectionStrings:PassWord"];
c.Key = app.Configuration["ConnectionStrings:Key"];
c.Port = Convert.ToInt32(app.Configuration["ConnectionStrings:Port"]);
});
//app.UseHadoop((c) =>
//{
// c.Host = "118.195.165.218";
// c.Account = "root";
// c.PassWord = "root";
// c.Key = "testdb";
// c.Port = 4000;
//});
9 months ago
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
}