This file contains 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
using Grpc.Net.Client; | |
using System.Threading.Tasks; | |
using MyServer; | |
namespace MyClient | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) | |
{ |
This file contains 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
using System.Threading.Tasks; | |
using Grpc.Core; | |
namespace MyServer | |
{ | |
public class OperacionService : OperacionMatematica.OperacionMatematicaBase | |
{ | |
public override Task<DivisionResponse> Divide(DivisionRequest request, ServerCallContext context) | |
{ | |
var result = new DivisionResponse(); |
This file contains 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
syntax = "proto3"; | |
option csharp_namespace = "MyServer"; | |
package greet; | |
service OperacionMatematica { | |
rpc Divide (DivisionRequest) returns (DivisionResponse); | |
} | |
message DivisionRequest { | |
int32 dividendo = 1; | |
int32 divisor = 2; | |
} |
This file contains 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
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
app.UseRouting(); | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapGrpcService<OperacionService>(); | |
endpoints.MapGet("/", async context => | |
{ | |
await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); | |
}); |
This file contains 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
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Routing; | |
using System.IO; | |
using System.Text; | |
await Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { |
This file contains 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
using System; | |
namespace MiniMicro | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Hello World!"); | |
} |
This file contains 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
builder.Services.AddAuthorization(); | |
builder.Services.AddAuthentication(options => | |
{ | |
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | |
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; | |
}).AddJwtBearer(o => | |
{ | |
o.RequireHttpsMetadata = false; | |
o.Authority = config.GetValue<string>("Jwt:Authority"); | |
o.Audience = config.GetValue<string>("Jwt:Audience"); |
This file contains 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
"Jwt" : { | |
"Authority" : "http://localhost:8080/auth/realms/iam", | |
"Audience": "webapp" | |
} |
This file contains 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.UseAuthentication(); | |
app.UseAuthorization(); |
This file contains 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.MapGet("/api/numero", [Authorize]() => { | |
var rng = new Random(); | |
int[] Numeros = Enumerable.Range(0, 100).ToArray<int>(); | |
return Enumerable.Range(1, 5).Select(index => | |
{ | |
var pos = rng.Next(1, Numeros.Length); | |
return Numeros[pos]; | |
}).ToArray(); | |
}); |
OlderNewer