当前位置: 首页 > 软件库 > 大数据 > 数据查询 >

aspnet-core-webapi

授权协议 Readme
开发语言 Java
所属分类 大数据、 数据查询
软件类型 开源软件
地区 不详
投 递 者 祁乐邦
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

aspnet-core-webapi

Esse é um projeto para futuras consultas de técnicas empregadas com ASP.NET Core 2.2 aplicando API-Guidelines da Microsoft.

Técnicas

  • RESTfull
  • Autenticação JWT
  • Swagger
  • Versionamento de API
  • Docker
  • HealthCheck - Utilizando a lib Xabaril/AspNetCore.Diagnostics.HealthChecks
    • Acessar o endpoint /healthz da api no browser
    • Acessar a url http://localhost:8003/healthchecks-ui para visualizar um painel com o monitoramento, disponível somente com docker-compose
  • App.Metrics + Prometheus + Grafana
  • FluentValidation
  • GraphQL
    • Acessar a url /ui/playground no browser
  • EF
    • MySQL
    • Migrations
  • Resiliência requisições Http(utilizando Polly)
    • Retry
    • Timeout
    • CircuitBreaker
  • Caching
    • Redis - Baseado nessa implementação
  • MessageBrokers
    • RabbitMQ
      • - Criação customizada de exchanges/queue por Atributos
  • SonarQube

GraphQL

Para utilizar o GraphQL é necessário ter um token de autenticação Bearer.Acessando a url https://localhost:5001/ui/playground terá disponível uma UI para realizar alguns testes ;)

Para adicionar novos personagens basta realizar as operações do contorller Dragon Ball.

Tipos disponívels:

type Character {
    id: int,
    name: string!,
    bithDate: string!,
    relatives: [Relative!],
    kind: Kind!
}

type Relative {
    id: int!,
    name: string!,
    bithDate: string!,
    relatives: [Relative!],
    relativeKind: RelativeKind!
}

enum Kind {
    HUMAN = 1,
    SAYAJIN = 2
}

enum RelativeKind {
    Brother = 1,
    Sister = 2,
    Son = 3,
    Daugther = 4,
    Spouse = 5,
    Father = 6 ,
    Mother = 7
}

Queries disponíveis

characters
character(id: int)

Mutations disponíveis

createCharacter(character: Character)

Docker

O arquivo Dockerfile já contém as instruções necessárias para serem buildadas, vamos executar o comando abaixo para compilar uma imagem.

docker build -t aspnet-core-webapi .

Docker-compose

O arquivo docker-compose.yml já contém as imagens necessárias para rodar a aplicação, basta executar o comando abaixo:

docker-compose build
docker-compose up

A porta do container é 80, porém estará pública na porta 8181.

E acessar a página http://localhost:8181/index.html

k8s

Para o exemplo vamos utilizar o docker stack que tem suporte ao Kubernetes.

Docker stack somente suporte imagens já buildadas

Vamos buildar todos os nossos softwares:

docker-compose build

e começar a brincadeira criando o namespace que vamos utilizar:

kubectl create namespace demo

e então criar o stack:

docker stack deploy --namespace demo -c docker-compose.yml appstack

e vamos validar nosso deployment:

kubectl get all -n demo

NAME                             READY     STATUS    RESTARTS   AGE
pod/healthapp-78959fcf7b-5xj6b   1/1       Running   0          12s
pod/mongodb-d5cc949f5-pqjqs      1/1       Running   0          12s
pod/mysqldb-5c8dccbd78-w5f8l     1/1       Running   0          12s
pod/rabbitmq-544d746545-hpm7d    1/1       Running   0          12s
pod/redis-d56fc6bdf-bmmds        1/1       Running   0          12s
pod/web-78bc8955d4-2sjkq         0/1       Error     0          12s

NAME                          TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                          AGE
service/healthapp             ClusterIP      None             <none>        55555/TCP                        12s
service/healthapp-published   LoadBalancer   10.97.148.148    localhost     8083:30610/TCP                   9s
service/mongodb               ClusterIP      None             <none>        55555/TCP                        9s
service/mongodb-published     LoadBalancer   10.100.145.160   localhost     27017:30231/TCP                  12s
service/mysqldb               ClusterIP      None             <none>        55555/TCP                        8s
service/mysqldb-published     LoadBalancer   10.105.66.236    localhost     3306:30969/TCP                   12s
service/rabbitmq              ClusterIP      None             <none>        55555/TCP                        12s
service/rabbitmq-published    LoadBalancer   10.104.157.0     localhost     5672:31170/TCP,15672:31195/TCP   7s
service/redis                 ClusterIP      None             <none>        55555/TCP                        7s
service/redis-published       LoadBalancer   10.104.50.187    localhost     6379:30003/TCP                   12s
service/web                   ClusterIP      None             <none>        55555/TCP                        12s
service/web-published         LoadBalancer   10.104.37.39     localhost     8181:30589/TCP                   8s

NAME                        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/healthapp   1         1         1            1           13s
deployment.apps/mongodb     1         1         1            1           13s
deployment.apps/mysqldb     1         1         1            1           12s
deployment.apps/rabbitmq    1         1         1            1           13s
deployment.apps/redis       1         1         1            1           13s
deployment.apps/web         1         1         1            0           13s

NAME                                   DESIRED   CURRENT   READY     AGE
replicaset.apps/healthapp-78959fcf7b   1         1         1         13s
replicaset.apps/mongodb-d5cc949f5      1         1         1         12s
replicaset.apps/mysqldb-5c8dccbd78     1         1         1         12s
replicaset.apps/rabbitmq-544d746545    1         1         1         13s
replicaset.apps/redis-d56fc6bdf        1         1         1         13s
replicaset.apps/web-78bc8955d4         1         1         0         13s

Para remover a stack:

docker stack rm appstack --namespace demo

SonarQube

Configuração

Subindo Análise

  • webapi 就是使用asp.net core使用c#创建Restful服务,就是webapi,如果要使用webapi控制器 webapi中的控制器是派生自ControllerBase的类, ControllerBase类 不要通过从 Controller 类派生来创建 Web API 控制器。 Controller 派生自 ControllerBase,并添加对视图的支持,因此它用于处理 Web

  • Introduction This document describes ASP.NET Core integration for ASP.NET Boilerplate framework. ASP.NET Core integration is implemented in Abp.AspNetCore nuget package 本文档介绍了ASP.NET样板ASP.NET核心集成框架。AS

  • 1. 安装包 Install-Package Microsoft.AspNet.WebApi.Cors 2. 启用配置 在WebApiConfig中启用Cors。 public static class WebApiConfig { public static void Register(HttpConfiguration config) {

  • Building Dynamic Web API Controllers This document is for ASP.NET Web API. If you're interested in ASP.NET Core, see ASP.NET Core documentation. ASP.NET Boilerplate can automatically generate ASP.NET

 相关资料
  • 8.3 ABP实时服务 - 集成Abp.AspNetCore.SignalR 8.3.1 简介 在基于ABP开发的应用中,为了更简单的使用ASP.NET Core SignalR,您可以 使用Abp.AspNetCore.SignalR 包。 注意:该软件包目前是 preview。如果您遇到问题,请提交issues给Github:https://github.com/aspnetboilerpla

  • 5.5 ABP分布式服务 - ASPNET Core 集成OData 5.5.1 简介 开放数据协议(Open Data Protocol,缩写OData)是一种描述如何创建和访问Restful服务。你可以在Abp中使用OData,只需要通过Nuget来安装Abp.AspNetCore.OData. 5.5.2 安装 1. 使用Nuget安装 首先应该使用Nuget安装Abp.AspNetCore

  • 本文向大家介绍AspNet Core上实现web定时任务实例,包括了AspNet Core上实现web定时任务实例的使用技巧和注意事项,需要的朋友参考一下 作为一枚后端程序狗,项目实践常遇到定时任务的工作,最容易想到的的思路就是利用Windows计划任务/wndows service程序/Crontab程序等主机方法在主机上部署定时任务程序/脚本。 但是很多时候,若使用的是共享主机或者受控主机,这

  • 当我通常使用Giraffe或ASP.NET Core时,我可以创建一个actor系统,将其作为服务添加,然后在请求处理程序选择任何actor并询问/告知消息的情况下获得它。 无论是使用cluster.sharding还是普通的,我知道它将是整个系统中actor的一个实例,处理多个消息。 如何与流进行相同的通信?它们似乎不是路由器中的引用,也不是作为执行元路径的执行元系统中的引用:执行元引用、路径和

  • 我有两个容器,一个容器用于MySQL,另一个容器用于dotnet核心。我能够在不安装CLR调试器的情况下运行它。在一个容器中安装CLR调试器后,我尝试使用Visual Studio代码调试在该容器中运行的aspnet Core2应用程序。我得到以下错误: “管道程序'bash'意外退出。” 唯一的选项是“打开launch.json”,并且launch.json中的bash命令只有: 我错过了什么?

  • Docker images for ASP.NET Core apps on Google Cloud This repo containes the definition of the Docker images for the .NET runtime to be able to run ASP.NET Core apps on App Engine Flexible environment