Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple data controller for taking incoming sensor data.
public class DataController : Controller
{
private readonly SampleWriter sampleWriter;
public DataController(SampleWriter sampleWriter)
{
this.sampleWriter = sampleWriter;
}
[HttpPost]
public async Task<ActionResult> ProvideReading(uint milliseconds, double speed)
{
// sampleWriter is just a singleton dependency with an open file stream,
// writing each record to a CSV file as it arrives.
await sampleWriter.ProvideSample(milliseconds, speed);
return StatusCode(200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.