Skip to content

Instantly share code, notes, and snippets.

@alistairjevans
Created May 26, 2019 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alistairjevans/7f0d74b80e7a20b115af3330bc3834bf to your computer and use it in GitHub Desktop.
Save alistairjevans/7f0d74b80e7a20b115af3330bc3834bf to your computer and use it in GitHub Desktop.
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