Created
March 12, 2023 15:13
-
-
Save GiveMeSomething/d300bd40be38da6808b6c73a2a9efe0d to your computer and use it in GitHub Desktop.
Protobuf file sharing endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapGet("/_proto/", async ctx => | |
{ | |
ctx.Response.ContentType = "text/plain"; | |
using var fs = new FileStream(Path.Combine(env.ContentRootPath, "Proto", "your.proto"), FileMode.Open, FileAccess.Read); | |
using var sr = new StreamReader(fs); | |
while (!sr.EndOfStream) | |
{ | |
var line = await sr.ReadLineAsync(); | |
if (line != "/* >>" || line != "<< */") | |
{ | |
await ctx.Response.WriteAsync(line); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment