Sorry guys this may seem like a novice question but I've never worked with endpoint mapping before and just can't seem to figure it out.
So I wrote a service which listens for requests, the body of said request contains a json object which my service needs to properly process the requests. While I know how to route those requests to the appropriate controller I just don't know how I am supposed to read and deliver the request body to the controller.
Startup.cs
class Startup
{
private readonly IHostingEnvironment _env;
private readonly IConfiguration _config;
private readonly ILoggerFactory _loggerFactory;
public Startup(IHostingEnvironment env, IConfiguration config,
ILoggerFactory loggerFactory)
{
_env = env;
_config = config;
_loggerFactory = loggerFactory;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddRouting();
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Classifier}/{action}");
});
}
}
Controller
public class ClassifierController : Controller
{
private Classifier documentClassifier = new Classifier();
public TrainingResponse Training(RequestTrainingData requestDataTrain)
{
return documentClassifier.Train(requestDataTrain);
}
public PredictionResponse Predict(RequestPredictionData requestDataPredict)
{
return documentClassifier.Predict(requestDataPredict);
}
}
As you can see I expect either a Object of type RequestPredictionData or RequestTrainingData:
RequestPredictionData
public class RequestPredictionData
{
public string Principal { get; set; }
public IEnumerable<PredictionInputDocument> Docs { get; set; }
}
RequestTrainingData
public class RequestTrainingData
{
public string Principal { get; set; }
public IEnumerable<TrainingDocument> Docs { get; set; }
}
Sorry for the rather long text and thanks to anyone that took the time to read my question^^'