├── .dockerignore ├── .gitattributes ├── .gitignore ├── NuGet.config ├── README.md ├── build-local-sdk-image.ps1 ├── build.ps1 ├── build └── Dockerfile-Sdk ├── cer.ps1 ├── deploy ├── charts │ ├── geektime-healthcheckshost │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── templates │ │ │ ├── NOTES.txt │ │ │ ├── _helpers.tpl │ │ │ ├── deployment.yaml │ │ │ ├── ingress.yaml │ │ │ ├── service.yaml │ │ │ ├── serviceaccount.yaml │ │ │ └── tests │ │ │ │ └── test-connection.yaml │ │ └── values.yaml │ ├── geektime-identity-api │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── templates │ │ │ ├── NOTES.txt │ │ │ ├── _helpers.tpl │ │ │ ├── deployment.yaml │ │ │ ├── ingress.yaml │ │ │ ├── service.yaml │ │ │ ├── serviceaccount.yaml │ │ │ └── tests │ │ │ │ └── test-connection.yaml │ │ └── values.yaml │ ├── geektime-mobile-apiaggregator │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── templates │ │ │ ├── NOTES.txt │ │ │ ├── _helpers.tpl │ │ │ ├── deployment.yaml │ │ │ ├── ingress.yaml │ │ │ ├── service.yaml │ │ │ ├── serviceaccount.yaml │ │ │ └── tests │ │ │ │ └── test-connection.yaml │ │ └── values.yaml │ ├── geektime-mobile-gateway │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── templates │ │ │ ├── NOTES.txt │ │ │ ├── _helpers.tpl │ │ │ ├── deployment.yaml │ │ │ ├── ingress.yaml │ │ │ ├── service.yaml │ │ │ ├── serviceaccount.yaml │ │ │ └── tests │ │ │ │ └── test-connection.yaml │ │ └── values.yaml │ └── geektime-ordering-api │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── templates │ │ ├── NOTES.txt │ │ ├── _helpers.tpl │ │ ├── deployment.yaml │ │ ├── ingress.yaml │ │ ├── service.yaml │ │ ├── serviceaccount.yaml │ │ └── tests │ │ │ └── test-connection.yaml │ │ └── values.yaml ├── deploy-helm.ps1 ├── deploy.ps1 ├── env.txt ├── geektime-healthcheckshost │ ├── configs │ │ └── appsettings-1.0.0.json │ └── geektime-healthcheckshost.yaml ├── geektime-identity-api │ └── configs │ │ └── appsettings-1.0.0.json ├── geektime-mobile-apiaggregator │ ├── configs │ │ └── appsettings-1.0.0.json │ └── geektime-mobile-apiaggregator.yaml ├── geektime-mobile-gateway │ ├── configs │ │ └── appsettings-1.0.0.json │ ├── geektime-mobile-gateway-ingress.yaml │ └── geektime-mobile-gateway.yaml ├── geektime-ordering-api │ ├── configs │ │ └── appsettings-1.0.0.json │ └── geektime-ordering-api.yaml ├── infrastructure │ ├── apollo │ │ ├── README.txt │ │ ├── docker-compose.yml │ │ ├── sql │ │ │ ├── apolloconfigdb.sql │ │ │ └── apolloportaldb.sql │ │ └── start.ps1 │ ├── cer │ │ ├── https-cer.ps1 │ │ ├── server.crt │ │ ├── server.key │ │ └── server.pem │ ├── deploy-all-in-one.ps1 │ ├── elasticsearch.yaml │ ├── exceptionless.yaml │ ├── fluentd.yaml │ ├── fluentd │ │ └── fluent.conf │ ├── grafana.yaml │ ├── init │ │ ├── chocolatey.ps1 │ │ ├── helm.ps1 │ │ ├── host.txt │ │ ├── ingress-port.yaml │ │ ├── init.ps1 │ │ ├── kubernetes-dashboard-ingress.yaml │ │ ├── kubernetes-dashboard.yaml │ │ ├── mandatory.yaml │ │ ├── prometheus-operator.ps1 │ │ ├── prometheus-operator │ │ │ ├── hc.yaml │ │ │ └── values.yaml │ │ └── token.ps1 │ ├── kibana.yaml │ ├── mysql.yaml │ ├── rabbitmq.yaml │ └── redis.yaml └── uninstall-by-helm.ps1 ├── microservices.sln ├── pdf ├── 第一章.pdf ├── 第三章 部署到Kubernetes.pdf ├── 第二章微服务实战篇.pdf └── 第二章微服务实战篇(下).pdf ├── samples ├── ConfigurationCommandLineDemo │ ├── ConfigurationCommandLineDemo.csproj │ ├── Program.cs │ └── Properties │ │ └── launchSettings.json ├── ConfigurationCustom │ ├── ConfigurationCustom.csproj │ ├── MyConfigurationBuilderExtensions.cs │ ├── MyConfigurationProvider.cs │ ├── MyConfigurationSource.cs │ └── Program.cs ├── ConfigurationDemo │ ├── ConfigurationDemo.csproj │ └── Program.cs ├── ConfigurationEnvironmentVariablesDemo │ ├── ConfigurationEnvironmentVariablesDemo.csproj │ ├── Program.cs │ └── Properties │ │ └── launchSettings.json ├── ConfigurationFileDemo │ ├── Class1.cs │ ├── ConfigurationFileDemo.csproj │ ├── Program.cs │ ├── appsettings.Development.json │ ├── appsettings.ini │ └── appsettings.json ├── DependencyInjectionAutofacDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── DependencyInjectionAutofacDemo.csproj │ ├── MyDI │ │ └── MyDI.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── Interceptor.cs │ │ └── MySerice.cs │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── DependencyInjectionDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── DependencyInjectionDemo.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── GenericService.cs │ │ ├── IService.cs │ │ ├── MyScopedService.cs │ │ ├── MySingletonService.cs │ │ ├── MyTransientService.cs │ │ └── OrderService.cs │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── DependencyInjectionScopeAndDisposableDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── DependencyInjectionScopeAndDisposableDemo.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ └── OrderService.cs │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── ExceptionDemo │ ├── Controllers │ │ ├── ErrorController.cs │ │ └── WeatherForecastController.cs │ ├── ExceptionDemo.csproj │ ├── Exceptions │ │ ├── IKnownException.cs │ │ ├── KnownException.cs │ │ ├── MyExceptionFilter.cs │ │ ├── MyExceptionFilterAttribute.cs │ │ └── MyServerException.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ │ └── Error │ │ │ └── Index.cshtml │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── FileProviderDemo │ ├── FileProviderDemo.csproj │ ├── Program.cs │ └── emb.html ├── GrpcClientDemo │ ├── Extensions │ │ └── PollyServiceCollectionExtensions.cs │ ├── GrpcClientDemo.csproj │ ├── Interceptors │ │ ├── ExceptionInterceptor.cs │ │ └── PollyInterceptor.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ └── Startup.cs ├── GrpcServerDemo │ ├── GrpcServerDemo.csproj │ ├── GrpcSrvices │ │ └── OrderService.cs │ ├── Interceptors │ │ └── ExceptionInterceptor.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Proto │ │ └── order.proto │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── HttpClientFactoryDemo │ ├── Clients │ │ ├── NamedOrderServiceClient.cs │ │ ├── OrderServiceClient.cs │ │ └── TypedOrderServiceClient.cs │ ├── Controllers │ │ └── OrderController.cs │ ├── DelegatingHandlers │ │ └── RequestIdDelegatingHandler.cs │ ├── HttpClientFactoryDemo.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── LoggingDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── LoggingDemo.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── LoggingScopeDemo │ ├── LoggingScopeDemo.csproj │ ├── Program.cs │ └── appsettings.json ├── LoggingSerilogDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── LoggingSerilogDemo.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── WeatherForecast.cs │ └── appsettings.json ├── LoggingSimpleDemo │ ├── LoggingSimpleDemo.csproj │ ├── OrderService.cs │ ├── Program.cs │ └── appsettings.json ├── MediatorDemo │ ├── MediatorDemo.csproj │ └── Program.cs ├── MiddlewareDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── MiddlewareDemo.csproj │ ├── Middlewares │ │ ├── MyBuilderExtensions.cs │ │ └── MyMiddleware.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── WeatherForecast.cs │ └── appsettings.json ├── OptionsDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── OptionsDemo.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── OrderService.cs │ │ └── OrderServiceExtensions.cs │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── RemoteSite │ ├── Controllers │ │ └── OrderServiceController.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── RemoteSite.csproj │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── RoutingDemo │ ├── Constraints │ │ └── MyRouteConstraint.cs │ ├── Controllers │ │ ├── OrderController.cs │ │ └── WeatherForecastController.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── RoutingDemo.csproj │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── Shared │ └── Shared.csproj ├── StartupDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── StartupDemo.csproj │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── StaticFilesDemo │ ├── Controllers │ │ └── WeatherForecastController.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── StaticFilesDemo.csproj │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── file │ │ └── page.html │ └── wwwroot │ │ ├── a │ │ ├── a.js │ │ └── index.html │ │ ├── app.js │ │ └── index.html └── samples.sln └── src ├── ApiGateways ├── GeekTime.Gateway │ ├── Dockerfile │ ├── GeekTime.Gateway.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── ocelot.json │ └── skyapm.json ├── GeekTime.Mobile.ApiAggregator │ ├── Controllers │ │ ├── OrderController.cs │ │ ├── TestController.cs │ │ └── WeatherForecastController.cs │ ├── Dockerfile │ ├── GeekTime.Mobile.ApiAggregator.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── IOrderService.cs │ │ ├── OrderService.cs │ │ └── OrderServiceClient.cs │ ├── Startup.cs │ ├── WeatherForecast.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── skyapm.json └── GeekTime.Mobile.Gateway │ ├── Controllers │ ├── AccountController.cs │ ├── BankAccountController.cs │ └── TestController.cs │ ├── Dockerfile │ ├── GeekTime.Mobile.Gateway.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── skyapm.json ├── Monitor └── GeekTime.HealthChecksHost │ ├── Controllers │ └── ExportersController.cs │ ├── Dockerfile │ ├── GeekTime.HealthChecksHost.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── Samples ├── GeekTime.BadSite │ ├── Controllers │ │ └── HomeController.cs │ ├── GeekTime.BadSite.csproj │ ├── Models │ │ └── ErrorViewModel.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ │ ├── Home │ │ │ ├── Cors.cshtml │ │ │ ├── Index.cshtml │ │ │ ├── Login.cshtml │ │ │ └── Privacy.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── css │ │ └── site.css │ │ ├── favicon.ico │ │ ├── js │ │ └── site.js │ │ └── lib │ │ ├── bootstrap │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-grid.css │ │ │ ├── bootstrap-grid.css.map │ │ │ ├── bootstrap-grid.min.css │ │ │ ├── bootstrap-grid.min.css.map │ │ │ ├── bootstrap-reboot.css │ │ │ ├── bootstrap-reboot.css.map │ │ │ ├── bootstrap-reboot.min.css │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ └── js │ │ │ ├── bootstrap.bundle.js │ │ │ ├── bootstrap.bundle.js.map │ │ │ ├── bootstrap.bundle.min.js │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.js.map │ │ │ ├── bootstrap.min.js │ │ │ └── bootstrap.min.js.map │ │ ├── jquery-validation-unobtrusive │ │ ├── LICENSE.txt │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ │ ├── jquery-validation │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ │ └── jquery │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map └── GeekTime.GoodSite │ ├── Controllers │ └── HomeController.cs │ ├── GeekTime.GoodSite.csproj │ ├── Models │ ├── ErrorViewModel.cs │ └── OrderModel.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Index.cshtml │ │ ├── Login.cshtml │ │ ├── Privacy.cshtml │ │ └── Show.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── Services ├── Identity │ └── GeekTime.Identity.API │ │ ├── Controllers │ │ └── WeatherForecastController.cs │ │ ├── Dockerfile │ │ ├── GeekTime.Identity.API.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── Startup.cs │ │ ├── WeatherForecast.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── skyapm.json └── Ordering │ ├── GeekTime.Ordering.API │ ├── Application │ │ ├── Commands │ │ │ ├── CreateOrderCommand.cs │ │ │ └── CreateOrderCommandHandler.cs │ │ ├── DomainEventHandlers │ │ │ └── OrderCreatedDomainEventHandler.cs │ │ ├── IntegrationEvents │ │ │ ├── ISubscriberService.cs │ │ │ ├── OrderCreatedIntegrationEvent.cs │ │ │ ├── OrderPaymentSucceededIntegrationEvent.cs │ │ │ └── SubscriberService.cs │ │ └── Queries │ │ │ ├── MyOrderQuery.cs │ │ │ └── MyOrderQueryHandler.cs │ ├── Controllers │ │ ├── HcController.cs │ │ ├── OrderController.cs │ │ └── TestController.cs │ ├── Dockerfile │ ├── Extensions │ │ ├── ApplicationBuilderExtensions.cs │ │ └── ServiceCollectionExtensions.cs │ ├── GeekTime.Ordering.API.csproj │ ├── Grpc │ │ ├── OrderServiceImpl.cs │ │ └── ordering.proto │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── skyapm.json │ ├── GeekTime.Ordering.BackgroundTasks │ ├── GeekTime.Ordering.BackgroundTasks.csproj │ └── Program.cs │ ├── GeekTime.Ordering.Domain │ ├── Events │ │ └── OrderCreatedDomainEvent.cs │ ├── GeekTime.Ordering.Domain.csproj │ └── OrderAggregate │ │ ├── Address.cs │ │ └── Order.cs │ └── GeekTime.Ordering.Infrastructure │ ├── EntityConfigurations │ └── OrderEntityTypeConfiguration.cs │ ├── GeekTime.Ordering.Infrastructure.csproj │ ├── OrderingContext.cs │ ├── OrderingContextTransactionBehavior.cs │ └── Repositories │ ├── IOrderRepository.cs │ └── OrderRepository.cs └── Shared ├── GeekTime.Core ├── GeekTime.Core.csproj ├── IKnownException.cs └── KnownException.cs ├── GeekTime.Domain.Abstractions ├── Entity.cs ├── GeekTime.Domain.Abstractions.csproj ├── IAggregateRoot.cs ├── IDomainEvent.cs ├── IDomainEventHandler.cs ├── IEntity.cs └── ValueObject.cs ├── GeekTime.Extensions.Http ├── GeekTime.Extensions.Http.csproj ├── HttpClientExtensions.cs └── HttpResponseMessageExtensions.cs └── GeekTime.Infrastructure.Core ├── Behaviors └── TransactionBehavior.cs ├── EFContext.cs ├── Extensions ├── GenericTypeExtensions.cs └── MediatorExtension.cs ├── GeekTime.Infrastructure.Core.csproj ├── IRepository.cs ├── ITransaction.cs ├── IUnitOfWork.cs └── Repository.cs /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 项目说明 2 | 3 | ## 部署 4 | 5 | 6 | ### 基础设施 7 | ``` 8 | MYSQL 9 | 10 | 主机端口:30001 11 | 容器端口:3306 12 | ``` 13 | 14 | ## GeekTime.HealthChecksHost 15 | 16 | 访问地址:http://localhost:30006/healthchecks-ui 17 | -------------------------------------------------------------------------------- /build-local-sdk-image.ps1: -------------------------------------------------------------------------------- 1 | docker build --no-cache -f .\build\Dockerfile-Sdk -t dotnet-local-sdk:3.1 . -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [parameter(Mandatory=$true)][string]$tag 3 | ) 4 | 5 | 6 | docker build --no-cache -f .\src\Services\Ordering\GeekTime.Ordering.API\Dockerfile -t geektime-ordering-api:$tag . 7 | docker build --no-cache -f .\src\Services\Identity\GeekTime.Identity.API\Dockerfile -t geektime-identity-api:$tag . 8 | docker build --no-cache -f .\src\ApiGateways\GeekTime.Mobile.Gateway\Dockerfile -t geektime-mobile-gateway:$tag . 9 | docker build --no-cache -f .\src\ApiGateways\GeekTime.Mobile.ApiAggregator\Dockerfile -t geektime-mobile-apiaggregator:$tag . 10 | docker build --no-cache -f .\src\Monitor\GeekTime.HealthChecksHost\Dockerfile -t geektime-healthcheckshost:$tag . 11 | 12 | "Any key to exit" ; 13 | Read-Host | Out-Null ; 14 | Exit -------------------------------------------------------------------------------- /build/Dockerfile-Sdk: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build 2 | COPY . . 3 | RUN dotnet restore --disable-parallel -v d -------------------------------------------------------------------------------- /deploy/charts/geektime-healthcheckshost/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /deploy/charts/geektime-healthcheckshost/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: geektime-healthcheckshost 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | version: 1.0.0 18 | 19 | # This is the version number of the application being deployed. This version number should be 20 | # incremented each time you make changes to the application. 21 | appVersion: 1.0.0 22 | -------------------------------------------------------------------------------- /deploy/charts/geektime-healthcheckshost/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "geektime-healthcheckshost.fullname" . }} 5 | labels: 6 | {{- include "geektime-healthcheckshost.labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | {{- include "geektime-healthcheckshost.selectorLabels" . | nindent 4 }} 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-healthcheckshost/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "geektime-healthcheckshost.serviceAccountName" . }} 6 | labels: 7 | {{ include "geektime-healthcheckshost.labels" . | nindent 4 }} 8 | {{- end -}} 9 | -------------------------------------------------------------------------------- /deploy/charts/geektime-healthcheckshost/templates/tests/test-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: "{{ include "geektime-healthcheckshost.fullname" . }}-test-connection" 5 | labels: 6 | {{ include "geektime-healthcheckshost.labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test-success 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include "geektime-healthcheckshost.fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-identity-api/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /deploy/charts/geektime-identity-api/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: geektime-identity-api 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | version: 1.0.0 18 | 19 | # This is the version number of the application being deployed. This version number should be 20 | # incremented each time you make changes to the application. 21 | appVersion: 1.0.0 22 | -------------------------------------------------------------------------------- /deploy/charts/geektime-identity-api/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | {{- $fullName := include "geektime-identity-api.fullname" . -}} 3 | {{- $svcPort := .Values.service.port -}} 4 | {{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} 5 | apiVersion: networking.k8s.io/v1beta1 6 | {{- else -}} 7 | apiVersion: extensions/v1beta1 8 | {{- end }} 9 | kind: Ingress 10 | metadata: 11 | name: {{ $fullName }} 12 | labels: 13 | {{- include "geektime-identity-api.labels" . | nindent 4 }} 14 | {{- with .Values.ingress.annotations }} 15 | annotations: 16 | {{- toYaml . | nindent 4 }} 17 | {{- end }} 18 | spec: 19 | {{- if .Values.ingress.tls }} 20 | tls: 21 | {{- range .Values.ingress.tls }} 22 | - hosts: 23 | {{- range .hosts }} 24 | - {{ . | quote }} 25 | {{- end }} 26 | secretName: {{ .secretName }} 27 | {{- end }} 28 | {{- end }} 29 | rules: 30 | {{- range .Values.ingress.hosts }} 31 | - host: {{ .host | quote }} 32 | http: 33 | paths: 34 | {{- range .paths }} 35 | - path: {{ . }} 36 | backend: 37 | serviceName: {{ $fullName }} 38 | servicePort: {{ $svcPort }} 39 | {{- end }} 40 | {{- end }} 41 | {{- end }} 42 | -------------------------------------------------------------------------------- /deploy/charts/geektime-identity-api/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "geektime-identity-api.fullname" . }} 5 | labels: 6 | {{- include "geektime-identity-api.labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | {{- include "geektime-identity-api.selectorLabels" . | nindent 4 }} 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-identity-api/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "geektime-identity-api.serviceAccountName" . }} 6 | labels: 7 | {{ include "geektime-identity-api.labels" . | nindent 4 }} 8 | {{- end -}} 9 | -------------------------------------------------------------------------------- /deploy/charts/geektime-identity-api/templates/tests/test-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: "{{ include "geektime-identity-api.fullname" . }}-test-connection" 5 | labels: 6 | {{ include "geektime-identity-api.labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test-success 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include "geektime-identity-api.fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-apiaggregator/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-apiaggregator/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: geektime-mobile-apiaggregator 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | version: 1.0.0 18 | 19 | # This is the version number of the application being deployed. This version number should be 20 | # incremented each time you make changes to the application. 21 | appVersion: 1.0.0 22 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-apiaggregator/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "geektime-mobile-apiaggregator.fullname" . }} 5 | labels: 6 | {{- include "geektime-mobile-apiaggregator.labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | {{- include "geektime-mobile-apiaggregator.selectorLabels" . | nindent 4 }} 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-apiaggregator/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "geektime-mobile-apiaggregator.serviceAccountName" . }} 6 | labels: 7 | {{ include "geektime-mobile-apiaggregator.labels" . | nindent 4 }} 8 | {{- end -}} 9 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-apiaggregator/templates/tests/test-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: "{{ include "geektime-mobile-apiaggregator.fullname" . }}-test-connection" 5 | labels: 6 | {{ include "geektime-mobile-apiaggregator.labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test-success 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include "geektime-mobile-apiaggregator.fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-gateway/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-gateway/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: geektime-mobile-gateway 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | version: 1.0.0 18 | 19 | # This is the version number of the application being deployed. This version number should be 20 | # incremented each time you make changes to the application. 21 | appVersion: 1.0.0 22 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-gateway/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "geektime-mobile-gateway.fullname" . }} 5 | labels: 6 | {{- include "geektime-mobile-gateway.labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | {{- include "geektime-mobile-gateway.selectorLabels" . | nindent 4 }} 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-gateway/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "geektime-mobile-gateway.serviceAccountName" . }} 6 | labels: 7 | {{ include "geektime-mobile-gateway.labels" . | nindent 4 }} 8 | {{- end -}} 9 | -------------------------------------------------------------------------------- /deploy/charts/geektime-mobile-gateway/templates/tests/test-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: "{{ include "geektime-mobile-gateway.fullname" . }}-test-connection" 5 | labels: 6 | {{ include "geektime-mobile-gateway.labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test-success 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include "geektime-mobile-gateway.fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never 16 | -------------------------------------------------------------------------------- /deploy/charts/geektime-ordering-api/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /deploy/charts/geektime-ordering-api/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: geektime-ordering-api 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | version: 1.0.0 18 | 19 | # This is the version number of the application being deployed. This version number should be 20 | # incremented each time you make changes to the application. 21 | appVersion: 1.0.0 22 | 23 | -------------------------------------------------------------------------------- /deploy/charts/geektime-ordering-api/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | {{- $fullName := include "geektime-ordering-api.fullname" . -}} 3 | {{- $svcPort := .Values.service.port -}} 4 | {{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} 5 | apiVersion: networking.k8s.io/v1beta1 6 | {{- else -}} 7 | apiVersion: extensions/v1beta1 8 | {{- end }} 9 | kind: Ingress 10 | metadata: 11 | name: {{ $fullName }} 12 | labels: 13 | {{- include "geektime-ordering-api.labels" . | nindent 4 }} 14 | {{- with .Values.ingress.annotations }} 15 | annotations: 16 | {{- toYaml . | nindent 4 }} 17 | {{- end }} 18 | spec: 19 | {{- if .Values.ingress.tls }} 20 | tls: 21 | {{- range .Values.ingress.tls }} 22 | - hosts: 23 | {{- range .hosts }} 24 | - {{ . | quote }} 25 | {{- end }} 26 | secretName: {{ .secretName }} 27 | {{- end }} 28 | {{- end }} 29 | rules: 30 | {{- range .Values.ingress.hosts }} 31 | - host: {{ .host | quote }} 32 | http: 33 | paths: 34 | {{- range .paths }} 35 | - path: {{ . }} 36 | backend: 37 | serviceName: {{ $fullName }} 38 | servicePort: {{ $svcPort }} 39 | {{- end }} 40 | {{- end }} 41 | {{- end }} 42 | -------------------------------------------------------------------------------- /deploy/charts/geektime-ordering-api/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "geektime-ordering-api.fullname" . }} 5 | labels: 6 | {{- include "geektime-ordering-api.labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: 80 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | - port: 81 15 | targetPort: http2 16 | protocol: TCP 17 | name: http2 18 | - port: 443 19 | targetPort: https 20 | protocol: TCP 21 | name: https 22 | selector: 23 | {{- include "geektime-ordering-api.selectorLabels" . | nindent 4 }} 24 | -------------------------------------------------------------------------------- /deploy/charts/geektime-ordering-api/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "geektime-ordering-api.serviceAccountName" . }} 6 | labels: 7 | {{ include "geektime-ordering-api.labels" . | nindent 4 }} 8 | {{- end -}} 9 | -------------------------------------------------------------------------------- /deploy/charts/geektime-ordering-api/templates/tests/test-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: "{{ include "geektime-ordering-api.fullname" . }}-test-connection" 5 | labels: 6 | {{ include "geektime-ordering-api.labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test-success 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include "geektime-ordering-api.fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never 16 | -------------------------------------------------------------------------------- /deploy/deploy.ps1: -------------------------------------------------------------------------------- 1 | kubectl create configmap geektime-ordering-api-config --from-file=geektime-ordering-api/configs -o yaml --dry-run | kubectl apply -f - 2 | kubectl apply -f .\geektime-ordering-api\geektime-ordering-api.yaml 3 | 4 | kubectl create configmap geektime-mobile-apiaggregator-config --from-file=geektime-mobile-apiaggregator/configs -o yaml --dry-run | kubectl apply -f - 5 | kubectl apply -f .\geektime-mobile-apiaggregator\geektime-mobile-apiaggregator.yaml 6 | 7 | 8 | 9 | kubectl create configmap geektime-config --from-env-file=env.txt -o yaml --dry-run | kubectl apply -f - 10 | 11 | kubectl create configmap geektime-mobile-gateway-config --from-file=geektime-mobile-gateway/configs -o yaml --dry-run | kubectl apply -f - 12 | kubectl apply -f .\geektime-mobile-gateway\geektime-mobile-gateway.yaml 13 | kubectl apply -f .\geektime-mobile-gateway\geektime-mobile-gateway-ingress.yaml 14 | 15 | 16 | kubectl create configmap geektime-healthcheckshost-config --from-file=geektime-healthcheckshost/configs -o yaml --dry-run | kubectl apply -f - 17 | kubectl apply -f .\geektime-healthcheckshost\geektime-healthcheckshost.yaml 18 | 19 | "Any key to exit" ; 20 | Read-Host | Out-Null ; 21 | Exit -------------------------------------------------------------------------------- /deploy/env.txt: -------------------------------------------------------------------------------- 1 | skywalking_hostingStartup=SkyAPM.Agent.AspNetCore 2 | skywalking_servers=192.168.125.118:11800 3 | exceptionless_serverUrl=http://exceptionless-api 4 | ENV_ABC=abc value from env v2 5 | ENV_Key2=key2 value from env 6 | ABC=EFG -------------------------------------------------------------------------------- /deploy/geektime-identity-api/configs/appsettings-1.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /deploy/geektime-mobile-apiaggregator/configs/appsettings-1.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "Kestrel": { 3 | "Endpoints": { 4 | "Http": { 5 | "Url": "http://+:80" 6 | }, 7 | "Https": { 8 | "Url": "http://+:81", 9 | "Protocols":"Http2" 10 | } 11 | } 12 | }, 13 | "Logging": { 14 | "LogLevel": { 15 | "Default": "Information", 16 | "Microsoft": "Warning", 17 | "Microsoft.Hosting.Lifetime": "Information" 18 | } 19 | }, 20 | "ServiceUrls": { 21 | "OrderingAPI": "https://geektime-ordering-api" 22 | }, 23 | "AllowedHosts": "*", 24 | "SecurityKey": "aabbccddffskldjfklajskdlfjlas234234234" 25 | } -------------------------------------------------------------------------------- /deploy/geektime-mobile-gateway/geektime-mobile-gateway-ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: geektime-mobile-gateway-ingress 5 | namespace: default 6 | annotations: 7 | nginx.ingress.kubernetes.io/proxy-connect-timeout: 30s 8 | nginx.ingress.kubernetes.io/proxy-send-timeout: 20s 9 | nginx.ingress.kubernetes.io/proxy-read-timeout: 20s 10 | nginx.ingress.kubernetes.io/proxy-body-size: 50m 11 | nginx.ingress.kubernetes.io/proxy-buffer-size: "16k" 12 | nginx.ingress.kubernetes.io/ssl-redirect: "true" 13 | nginx.ingress.kubernetes.io/force-ssl-redirect: "true" 14 | nginx.ingress.kubernetes.io/rewrite-target: "/" 15 | spec: 16 | rules: 17 | - host: localhost 18 | http: 19 | paths: 20 | - path: / 21 | backend: 22 | serviceName: geektime-mobile-gateway 23 | servicePort: 80 -------------------------------------------------------------------------------- /deploy/geektime-ordering-api/configs/appsettings-1.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "Kestrel": { 3 | "Endpoints": { 4 | "Http": { 5 | "Url": "http://+:80" 6 | }, 7 | "Http2": { 8 | "Url": "http://+:81", 9 | "Protocols": "Http2" 10 | }, 11 | "Https": { 12 | "Url": "https://+:443" 13 | } 14 | }, 15 | "Certificates": { 16 | "Default": { 17 | "Path": "cer.pfx", 18 | "Password": "123456" 19 | } 20 | } 21 | }, 22 | "AllowedHosts": "*", 23 | "Mysql": "server=mysql;port=3306;user id=root;password=123456;database=geektime;charset=utf8mb4;ConnectionReset=false;", 24 | "RabbitMQ": { 25 | "HostName": "rabbitmq", 26 | "UserName": "guest", 27 | "Password": "guest", 28 | "VirtualHost": "/", 29 | "ExchangeName": "geek_queue" 30 | }, 31 | "exceptionless": { 32 | "ApiKey": "PSaokqmXC8T4xgWal9I0atA8TlYG7Ytz65JvxAL3" 33 | } 34 | } -------------------------------------------------------------------------------- /deploy/infrastructure/apollo/README.txt: -------------------------------------------------------------------------------- 1 | 前置条件,需要安装docker环境和docker-compose支持 2 | 在当前目录执行start.ps1,启动服务 3 | 4 | dashboard: 5 | http://localhost:8070 6 | 7 | 用户名: apollo 8 | 密码: admin 9 | 10 | 11 | configServer: 12 | http://localhost:8080 13 | 14 | -------------------------------------------------------------------------------- /deploy/infrastructure/apollo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | apollo-quick-start: 5 | image: nobodyiam/apollo-quick-start 6 | container_name: apollo-quick-start 7 | depends_on: 8 | - apollo-db 9 | ports: 10 | - "8080:8080" 11 | - "8070:8070" 12 | links: 13 | - apollo-db 14 | 15 | apollo-db: 16 | image: mysql:5.7 17 | container_name: apollo-db 18 | environment: 19 | TZ: Asia/Shanghai 20 | MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' 21 | depends_on: 22 | - apollo-dbdata 23 | ports: 24 | - "13306:3306" 25 | volumes: 26 | - ./sql:/docker-entrypoint-initdb.d 27 | volumes_from: 28 | - apollo-dbdata 29 | 30 | apollo-dbdata: 31 | image: alpine:latest 32 | container_name: apollo-dbdata 33 | volumes: 34 | - /var/lib/mysql 35 | -------------------------------------------------------------------------------- /deploy/infrastructure/apollo/start.ps1: -------------------------------------------------------------------------------- 1 | docker-compose up -------------------------------------------------------------------------------- /deploy/infrastructure/cer/https-cer.ps1: -------------------------------------------------------------------------------- 1 | kubectl create secret tls https-secret --key server.key --cert server.crt -n kube-system -------------------------------------------------------------------------------- /deploy/infrastructure/cer/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDOTCCAiGgAwIBAgIQMPyY9nQ+mYNNdlRKdONFzTANBgkqhkiG9w0BAQsFADAT 3 | MREwDwYDVQQDDAhnZWVrdGltZTAeFw0yMDAyMjkwNDQzMTdaFw0zMDAyMjgwNDQz 4 | MTdaMBMxETAPBgNVBAMMCGdlZWt0aW1lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A 5 | MIIBCgKCAQEA0iI1Szny3mV92SwezqdXgUv/XKknkrsrcf2x6da/CNFpFVn+Y+EU 6 | KKAkbYuvcs3cZssojSeDA/xrKEQrJLMjNrvIqgRG1E2lAli7ZRDaNF3E1WFChXe7 7 | OdvggK0f0ghNLqmOX7uxpJ4U6hlMN/veshxBQGQbnei/3vUjcuGv5A0rzbUUQs43 8 | sfsl6y9RDE7odqQLN4m8LhAAa+1LVc56qgQvRpyR8hGtpWmNe4kiliEjfEKIqxLn 9 | dOOmQCt5N+N+sKQTOkimXZT6oarM1xcCRsj+7i4rVpgWxus3uh5OOZzBbSmqghsi 10 | Z10JxgBG3g5kZoo1UM5XcpcyZQhbGvSGPQIDAQABo4GIMIGFMA4GA1UdDwEB/wQE 11 | AwIEsDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwNQYDVR0RBC4wLIIJ 12 | bG9jYWxob3N0ggcqLmxvY2FshwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1Ud 13 | DgQWBBSTAgjSnKWmCGp5CyvyUB620j6wXzANBgkqhkiG9w0BAQsFAAOCAQEAVFbr 14 | wVZrD+MH/7/uaVN4Ph0+ib+cD3zoLNugmxLocRRtIzMDkUSUETUx0UzqpUN5tnKf 15 | vwkix4gvWjw4CgdG4KlBNi9CzqE3UyZmLQbJMbkmm+th+ay8PHzjH72JAEfXtngD 16 | O9c93qoRGRDrnL3iIpP+aSqR72U593EcOn2in6Ovh5QE1lEzgs9f/d+SJjd7EWsF 17 | iACB6g5vp2YAkjqoxJBcJVmIEUzaT3JHxypx4JX96XTWGF8uJ0mFtJmJ5QV+Q/lO 18 | Uh91lNprdwy4tbECedPNVrNhi2pG0styDz5O7jHQYNbrP//gjaU+VuGhpjwC87ww 19 | SL2k2yh/jF7xOhpt6w== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /deploy/infrastructure/deploy-all-in-one.ps1: -------------------------------------------------------------------------------- 1 | kubectl create configmap fluentd-config --from-file=fluentd -o yaml --dry-run | kubectl apply -f - 2 | kubectl apply -f . -------------------------------------------------------------------------------- /deploy/infrastructure/grafana.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: grafana 5 | namespace: default 6 | labels: 7 | tag: grafana 8 | spec: 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: grafana 14 | spec: 15 | containers: 16 | - name: grafana 17 | image: "grafana/grafana:6.5.2" 18 | imagePullPolicy: IfNotPresent 19 | ports: 20 | - containerPort: 3000 21 | resources: 22 | limits: 23 | cpu: 1000m 24 | memory: 2048Mi 25 | requests: 26 | cpu: 100m 27 | memory: 256Mi 28 | terminationGracePeriodSeconds: 10 29 | restartPolicy: Always 30 | 31 | --- 32 | 33 | 34 | apiVersion: v1 35 | kind: Service 36 | metadata: 37 | name: grafana 38 | namespace: default 39 | labels: 40 | tag: "grafana" 41 | spec: 42 | type: NodePort 43 | ports: 44 | - nodePort: 30015 45 | port: 3000 46 | targetPort: 3000 47 | protocol: TCP 48 | selector: 49 | app: grafana -------------------------------------------------------------------------------- /deploy/infrastructure/init/chocolatey.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -------------------------------------------------------------------------------- /deploy/infrastructure/init/helm.ps1: -------------------------------------------------------------------------------- 1 | # Use Chocolatey on Windows 2 | # 注:安装的时候需要保证网络能够访问googleapis这个域名 3 | # 本行命令需要需要管理员身份 4 | choco install kubernetes-helm 5 | 6 | # Change helm repo 7 | helm repo add stable http://mirror.azure.cn/kubernetes/charts/ 8 | 9 | # Update charts repo 10 | helm repo update -------------------------------------------------------------------------------- /deploy/infrastructure/init/host.txt: -------------------------------------------------------------------------------- 1 | 127.0.0.1 kubernetes-dashboard.local 2 | 127.0.0.1 grafana.local 3 | 127.0.0.1 alertmanager.local 4 | 127.0.0.1 prometheus.local 5 | 127.0.0.1 healthchecks.local -------------------------------------------------------------------------------- /deploy/infrastructure/init/ingress-port.yaml: -------------------------------------------------------------------------------- 1 | kind: Service 2 | apiVersion: v1 3 | metadata: 4 | name: ingress-nginx 5 | namespace: ingress-nginx 6 | labels: 7 | app.kubernetes.io/name: ingress-nginx 8 | app.kubernetes.io/part-of: ingress-nginx 9 | spec: 10 | externalTrafficPolicy: Local 11 | type: LoadBalancer 12 | selector: 13 | app.kubernetes.io/name: ingress-nginx 14 | app.kubernetes.io/part-of: ingress-nginx 15 | ports: 16 | - name: http 17 | port: 81 18 | targetPort: http 19 | - name: https 20 | port: 443 21 | targetPort: https 22 | 23 | --- 24 | -------------------------------------------------------------------------------- /deploy/infrastructure/init/init.ps1: -------------------------------------------------------------------------------- 1 | kubectl apply -f mandatory.yaml 2 | kubectl apply -f ingress-port.yaml 3 | kubectl apply -f kubernetes-dashboard.yaml 4 | kubectl apply -f kubernetes-dashboard-ingress.yaml 5 | 6 | $TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1] 7 | kubectl config set-credentials docker-for-desktop --token="${TOKEN}" 8 | echo $TOKEN 9 | 10 | "Any key to exit" ; 11 | Read-Host | Out-Null ; 12 | Exit -------------------------------------------------------------------------------- /deploy/infrastructure/init/kubernetes-dashboard-ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: kubernetes-dashboard-ingress 5 | namespace: kube-system 6 | annotations: 7 | nginx.ingress.kubernetes.io/ingress.class: nginx 8 | nginx.ingress.kubernetes.io/secure-backends: "true" 9 | nginx.ingress.kubernetes.io/ssl-passthrough: "true" 10 | nginx.ingress.kubernetes.io/rewrite-target: "/" 11 | nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" 12 | spec: 13 | tls: 14 | - hosts: 15 | - kubernetes-dashboard.local 16 | secretName: https-secret 17 | rules: 18 | - host: kubernetes-dashboard.local 19 | http: 20 | paths: 21 | - path: / 22 | backend: 23 | serviceName: kubernetes-dashboard 24 | servicePort: 8443 -------------------------------------------------------------------------------- /deploy/infrastructure/init/prometheus-operator.ps1: -------------------------------------------------------------------------------- 1 | helm repo add stable http://mirror.azure.cn/kubernetes/charts/ 2 | helm repo update 3 | helm upgrade prometheus-operator stable/prometheus-operator --version 8.10.0 --values .\prometheus-operator\values.yaml --namespace kube-system -------------------------------------------------------------------------------- /deploy/infrastructure/init/prometheus-operator/hc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | app: prometheus-operator-healthchecks 6 | name: prometheus-operator-healthchecks 7 | namespace: kube-system 8 | spec: 9 | endpoints: 10 | - path: /metrics 11 | port: "80" 12 | namespaceSelector: 13 | any: true 14 | selector: 15 | matchLabels: 16 | app.kubernetes.io/instance: geektime-healthcheckshost 17 | app.kubernetes.io/name: geektime-healthcheckshost 18 | -------------------------------------------------------------------------------- /deploy/infrastructure/init/token.ps1: -------------------------------------------------------------------------------- 1 | $TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1] 2 | kubectl config set-credentials docker-for-desktop --token="${TOKEN}" 3 | echo $TOKEN 4 | 5 | "Any key to exit" ; 6 | Read-Host | Out-Null ; 7 | Exit -------------------------------------------------------------------------------- /deploy/infrastructure/kibana.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: kibana 5 | namespace: default 6 | labels: 7 | tag: kibana 8 | spec: 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: kibana 14 | spec: 15 | containers: 16 | - name: kibana 17 | image: "kibana:6.8.6" 18 | imagePullPolicy: IfNotPresent 19 | env: 20 | - name: discovery.type 21 | value: "single-node" 22 | - name: XPACK_MONITORING_ENABLED 23 | value: "true" 24 | ports: 25 | - containerPort: 5601 26 | resources: 27 | limits: 28 | cpu: 1000m 29 | memory: 2048Mi 30 | requests: 31 | cpu: 100m 32 | memory: 512Mi 33 | terminationGracePeriodSeconds: 10 34 | restartPolicy: Always 35 | 36 | --- 37 | 38 | 39 | apiVersion: v1 40 | kind: Service 41 | metadata: 42 | name: kibana 43 | namespace: default 44 | labels: 45 | tag: "kibana" 46 | spec: 47 | type: NodePort 48 | ports: 49 | - nodePort: 30009 50 | port: 5601 51 | targetPort: 5601 52 | protocol: TCP 53 | selector: 54 | app: kibana -------------------------------------------------------------------------------- /deploy/uninstall-by-helm.ps1: -------------------------------------------------------------------------------- 1 | helm uninstall geektime-ordering-api -n default 2 | helm uninstall geektime-identity-api -n default 3 | helm uninstall geektime-mobile-apiaggregator -n default 4 | helm uninstall geektime-mobile-gateway -n default 5 | helm uninstall geektime-healthcheckshost -n default 6 | 7 | "Any key to exit" ; 8 | Read-Host | Out-Null ; 9 | Exit -------------------------------------------------------------------------------- /pdf/第一章.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/pdf/第一章.pdf -------------------------------------------------------------------------------- /pdf/第三章 部署到Kubernetes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/pdf/第三章 部署到Kubernetes.pdf -------------------------------------------------------------------------------- /pdf/第二章微服务实战篇.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/pdf/第二章微服务实战篇.pdf -------------------------------------------------------------------------------- /pdf/第二章微服务实战篇(下).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/pdf/第二章微服务实战篇(下).pdf -------------------------------------------------------------------------------- /samples/ConfigurationCommandLineDemo/ConfigurationCommandLineDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/ConfigurationCommandLineDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.Extensions.Configuration; 4 | namespace ConfigurationCommandLineDemo 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var builder = new ConfigurationBuilder(); 11 | 12 | //builder.AddCommandLine(args); 13 | 14 | #region 命令替换 15 | var mapper = new Dictionary { { "--k1", "CommandLineKey1" } }; 16 | builder.AddCommandLine(args, mapper); 17 | #endregion 18 | 19 | var configurationRoot = builder.Build(); 20 | 21 | Console.WriteLine($"CommandLineKey1:{configurationRoot["CommandLineKey1"]}"); 22 | Console.WriteLine($"CommandLineKey2:{configurationRoot["CommandLineKey2"]}"); 23 | Console.WriteLine($"CommandLineKey3:{configurationRoot["CommandLineKey3"]}"); 24 | Console.ReadKey(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/ConfigurationCommandLineDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "ConfigurationCommandLineDemo": { 4 | "commandName": "Project", 5 | "commandLineArgs": "CommandLineKey1=value1 --CommandLineKey2=value2 CommandLineKey3 value3 --k1=k3" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /samples/ConfigurationCustom/ConfigurationCustom.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/ConfigurationCustom/MyConfigurationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using ConfigurationCustom; 5 | namespace Microsoft.Extensions.Configuration 6 | { 7 | public static class MyConfigurationBuilderExtensions 8 | { 9 | public static IConfigurationBuilder AddMyConfiguration(this IConfigurationBuilder builder) 10 | { 11 | builder.Add(new MyConfigurationSource()); 12 | return builder; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/ConfigurationCustom/MyConfigurationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Timers; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.Primitives; 7 | 8 | namespace ConfigurationCustom 9 | { 10 | class MyConfigurationProvider : ConfigurationProvider 11 | { 12 | 13 | Timer timer; 14 | 15 | public MyConfigurationProvider() : base() 16 | { 17 | timer = new Timer(); 18 | timer.Elapsed += Timer_Elapsed; 19 | timer.Interval = 3000; 20 | timer.Start(); 21 | } 22 | 23 | private void Timer_Elapsed(object sender, ElapsedEventArgs e) 24 | { 25 | Load(true); 26 | } 27 | 28 | public override void Load() 29 | { 30 | //加载数据 31 | Load(false); 32 | } 33 | 34 | void Load(bool reload) 35 | { 36 | this.Data["lastTime"] = DateTime.Now.ToString(); 37 | if (reload) 38 | { 39 | base.OnReload(); 40 | } 41 | } 42 | 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /samples/ConfigurationCustom/MyConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.Extensions.Configuration; 5 | namespace ConfigurationCustom 6 | { 7 | class MyConfigurationSource : IConfigurationSource 8 | { 9 | public IConfigurationProvider Build(IConfigurationBuilder builder) 10 | { 11 | return new MyConfigurationProvider(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/ConfigurationCustom/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Primitives; 4 | namespace ConfigurationCustom 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var builder = new ConfigurationBuilder(); 11 | builder.AddMyConfiguration(); 12 | 13 | var configRoot = builder.Build(); 14 | 15 | ChangeToken.OnChange(() => configRoot.GetReloadToken(), () => 16 | { 17 | Console.WriteLine($"lastTime:{configRoot["lastTime"]}"); 18 | }); 19 | 20 | Console.WriteLine("开始了"); 21 | Console.ReadKey(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/ConfigurationDemo/ConfigurationDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/ConfigurationEnvironmentVariablesDemo/ConfigurationEnvironmentVariablesDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/ConfigurationEnvironmentVariablesDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using System; 3 | 4 | namespace ConfigurationEnvironmentVariablesDemo 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var builder = new ConfigurationBuilder(); 11 | //builder.AddEnvironmentVariables(); 12 | 13 | //var configurationRoot = builder.Build(); 14 | //Console.WriteLine($"key1:{configurationRoot["key1"]}"); 15 | 16 | 17 | //#region 分层键 18 | //var section = configurationRoot.GetSection("SECTION1"); 19 | //Console.WriteLine($"KEY3:{section["KEY3"]}"); 20 | 21 | //var section2 = configurationRoot.GetSection("SECTION1:SECTION2"); 22 | //Console.WriteLine($"KEY4:{section2["KEY4"]}"); 23 | //#endregion 24 | 25 | #region 前缀过滤 26 | builder.AddEnvironmentVariables("XIAO_"); 27 | var configurationRoot = builder.Build(); 28 | Console.WriteLine($"KEY1:{configurationRoot["KEY1"]}"); 29 | Console.WriteLine($"KEY2:{configurationRoot["KEY2"]}"); 30 | #endregion 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/ConfigurationEnvironmentVariablesDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "ConfigurationEnvironmentVariablesDemo": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "KEY1": "value1", 7 | "KEY2": "value2", 8 | "SECTION1__KEY3": "value3", 9 | "SECTION1__SECTION2__KEY4": "value4", 10 | "XIAO_KEY1": "xiao key1" 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /samples/ConfigurationFileDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Key2": "Development Value2" 3 | } 4 | -------------------------------------------------------------------------------- /samples/ConfigurationFileDemo/appsettings.ini: -------------------------------------------------------------------------------- 1 | Key3=Value3 in ini -------------------------------------------------------------------------------- /samples/ConfigurationFileDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Key2": "Value2", 3 | "Key6": 0, 4 | "OrderService": { 5 | "Key1": "order key1", 6 | "Key5": true, 7 | "Key6": 200 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/DependencyInjectionAutofacDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using Autofac.Extensions.DependencyInjection; 10 | using DependencyInjectionAutofacDemo.MyDI; 11 | 12 | namespace DependencyInjectionAutofacDemo 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateHostBuilder(args).Build().Run(); 19 | } 20 | 21 | public static IHostBuilder CreateHostBuilder(string[] args) => 22 | Host.CreateDefaultBuilder(args) 23 | .UseServiceProviderFactory(new AutofacServiceProviderFactory()) 24 | .ConfigureWebHostDefaults(webBuilder => 25 | { 26 | webBuilder.UseStartup(); 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:2894", 8 | "sslPort": 44321 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "DependencyInjectionAutofacDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/Services/Interceptor.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace DependencyInjectionAutofacDemo.Services 8 | { 9 | public class MyInterceptor : IInterceptor 10 | { 11 | public void Intercept(IInvocation invocation) 12 | { 13 | Console.WriteLine($"Intercept before,Method:{invocation.Method.Name}"); 14 | //invocation.Proceed(); 15 | Console.WriteLine($"Intercept after,Method:{invocation.Method.Name}"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/Services/MySerice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionAutofacDemo.Services 7 | { 8 | public interface IMyService 9 | { 10 | void ShowCode(); 11 | } 12 | public class MyService : IMyService 13 | { 14 | public void ShowCode() 15 | { 16 | Console.WriteLine($"MyService.ShowCode:{GetHashCode()}"); 17 | } 18 | } 19 | 20 | public class MyServiceV2 : IMyService 21 | { 22 | public MyNameService NameService { get; set; } 23 | 24 | public void ShowCode() 25 | { 26 | Console.WriteLine($"MyServiceV2.ShowCode:{GetHashCode()},NameService是否为空:{NameService == null}"); 27 | } 28 | } 29 | 30 | 31 | public class MyNameService 32 | { 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/DependencyInjectionAutofacDemo/Startup.cs -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DependencyInjectionAutofacDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/DependencyInjectionAutofacDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/DependencyInjectionDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace DependencyInjectionDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:2655", 8 | "sslPort": 44356 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "DependencyInjectionDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast/getservicelist", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Services/GenericService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionDemo.Services 7 | { 8 | 9 | public interface IGenericService 10 | { 11 | 12 | } 13 | 14 | public class GenericService : IGenericService 15 | { 16 | public T Data { get; private set; } 17 | public GenericService(T data) 18 | { 19 | this.Data = data; 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Services/IService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionDemo.Services 7 | { 8 | public interface IService 9 | { 10 | Guid GetId(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Services/MyScopedService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionDemo.Services 7 | { 8 | public interface IMyScopedService { } 9 | public class MyScopedService : IMyScopedService 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Services/MySingletonService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionDemo.Services 7 | { 8 | 9 | public interface IMySingletonService 10 | { 11 | 12 | } 13 | 14 | public class MySingletonService : IMySingletonService 15 | { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Services/MyTransientService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionDemo.Services 7 | { 8 | public interface IMyTransientService 9 | { 10 | 11 | } 12 | public class MyTransientService : IMyTransientService 13 | { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Services/OrderService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DependencyInjectionDemo.Services 7 | { 8 | 9 | public interface IOrderService 10 | { 11 | 12 | } 13 | 14 | public class OrderService : IOrderService 15 | { 16 | 17 | } 18 | 19 | 20 | public class OrderServiceEx : IOrderService 21 | { 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/DependencyInjectionDemo/Startup.cs -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DependencyInjectionDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/DependencyInjectionDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/DependencyInjectionScopeAndDisposableDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace DependencyInjectionScopeAndDisposableDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:2850", 8 | "sslPort": 44317 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "DependencyInjectionScopeAndDisposableDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/Services/OrderService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.Extensions.Logging; 6 | namespace DependencyInjectionScopeAndDisposableDemo.Services 7 | { 8 | 9 | public interface IOrderService 10 | { 11 | 12 | } 13 | 14 | public class DisposableOrderService : IOrderService, IDisposable 15 | { 16 | public void Dispose() 17 | { 18 | Console.WriteLine($"DisposableOrderService Disposed:{this.GetHashCode()}"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/DependencyInjectionScopeAndDisposableDemo/Startup.cs -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DependencyInjectionScopeAndDisposableDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/DependencyInjectionScopeAndDisposableDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/ExceptionDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/Exceptions/IKnownException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace ExceptionDemo.Exceptions 7 | { 8 | public interface IKnownException 9 | { 10 | public string Message { get; } 11 | 12 | public int ErrorCode { get; } 13 | 14 | public object[] ErrorData { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/Exceptions/KnownException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace ExceptionDemo.Exceptions 7 | { 8 | public class KnownException : IKnownException 9 | { 10 | public string Message { get; private set; } 11 | 12 | public int ErrorCode { get; private set; } 13 | 14 | public object[] ErrorData { get; private set; } 15 | 16 | public readonly static IKnownException Unknown = new KnownException { Message = "未知错误", ErrorCode = 9999 }; 17 | 18 | public static IKnownException FromKnownException(IKnownException exception) 19 | { 20 | return new KnownException { Message = exception.Message, ErrorCode = exception.ErrorCode, ErrorData = exception.ErrorData }; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/Exceptions/MyServerException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace ExceptionDemo.Exceptions 7 | { 8 | public class MyServerException : Exception, IKnownException 9 | { 10 | public MyServerException(string message, int errorCode, params object[] errorData) : base(message) 11 | { 12 | this.ErrorCode = errorCode; 13 | this.ErrorData = errorData; 14 | } 15 | 16 | public int ErrorCode { get; private set; } 17 | public object[] ErrorData { get; private set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace ExceptionDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:24452", 8 | "sslPort": 44336 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "ExceptionDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/Views/Error/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model ExceptionDemo.Exceptions.IKnownException 2 | @{ 3 | ViewData["Title"] = "Index"; 4 | } 5 | 6 |

错误信息

7 | 8 |
Message:
9 |
ErrorCode
10 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ExceptionDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/ExceptionDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/FileProviderDemo/FileProviderDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /samples/FileProviderDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.FileProviders; 3 | namespace FileProviderDemo 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | IFileProvider provider1 = new PhysicalFileProvider(AppDomain.CurrentDomain.BaseDirectory); 10 | 11 | //var contents = provider1.GetDirectoryContents("/"); 12 | 13 | 14 | //foreach (var item in contents) 15 | //{ 16 | // Console.WriteLine(item.Name); 17 | //} 18 | 19 | IFileProvider provider2 = new EmbeddedFileProvider(typeof(Program).Assembly); 20 | 21 | 22 | var html = provider2.GetFileInfo("emb.html"); 23 | 24 | IFileProvider provider = new CompositeFileProvider(provider1, provider2); 25 | 26 | 27 | 28 | var contents = provider.GetDirectoryContents("/"); 29 | 30 | 31 | foreach (var item in contents) 32 | { 33 | Console.WriteLine(item.Name); 34 | } 35 | 36 | //Console.ReadKey(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/FileProviderDemo/emb.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/GrpcClientDemo/GrpcClientDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp3.1 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/GrpcClientDemo/Interceptors/ExceptionInterceptor.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Grpc.Core.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Polly; 8 | namespace GrpcClientDemo.Interceptors 9 | { 10 | public class ExceptionInterceptor : Interceptor 11 | { 12 | public override AsyncUnaryCall AsyncUnaryCall(TRequest request, ClientInterceptorContext context, AsyncUnaryCallContinuation continuation) 13 | { 14 | 15 | return base.AsyncUnaryCall(request, context, continuation); 16 | } 17 | 18 | public override TResponse BlockingUnaryCall(TRequest request, ClientInterceptorContext context, BlockingUnaryCallContinuation continuation) 19 | { 20 | try 21 | { 22 | return base.BlockingUnaryCall(request, context, continuation); 23 | } 24 | catch (RpcException ex) 25 | { 26 | ///记录日志 27 | throw; 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/GrpcClientDemo/Interceptors/PollyInterceptor.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Grpc.Core.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Polly; 8 | namespace GrpcClientDemo.Interceptors 9 | { 10 | public class PollyInterceptor : Interceptor 11 | { 12 | public override AsyncUnaryCall AsyncUnaryCall(TRequest request, ClientInterceptorContext context, AsyncUnaryCallContinuation continuation) 13 | { 14 | var policy = Policy.Handle().Retry(3); 15 | return policy.Execute(() => base.AsyncUnaryCall(request, context, continuation)); 16 | } 17 | 18 | public override TResponse BlockingUnaryCall(TRequest request, ClientInterceptorContext context, BlockingUnaryCallContinuation continuation) 19 | { 20 | var policy = Policy.Handle().Retry(3); 21 | return policy.Execute(() => base.BlockingUnaryCall(request, context, continuation)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/GrpcClientDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GrpcClientDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/GrpcClientDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:9284/", 7 | "sslPort": 44363 8 | } 9 | }, 10 | "profiles": { 11 | "GrpcClientDemo": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "applicationUrl": "https://localhost:5004;http://localhost:5003", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/GrpcClientDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/GrpcClientDemo/Startup.cs -------------------------------------------------------------------------------- /samples/GrpcServerDemo/GrpcServerDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /samples/GrpcServerDemo/GrpcSrvices/OrderService.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using GrpcServices; 3 | using System.Threading.Tasks; 4 | 5 | namespace GrpcServerDemo.GrpcServices 6 | { 7 | public class OrderService : OrderGrpc.OrderGrpcBase 8 | { 9 | public override Task CreateOrder(CreateOrderCommand request, ServerCallContext context) 10 | { 11 | 12 | throw new System.Exception("order error"); 13 | 14 | //添加创建订单的内部逻辑,录入将订单信息存储到数据库 15 | return Task.FromResult(new CreateOrderResult { OrderId = 24 }); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/GrpcServerDemo/Interceptors/ExceptionInterceptor.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Grpc.Core.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace GrpcServerDemo.Interceptors 9 | { 10 | public class ExceptionInterceptor : Interceptor 11 | { 12 | public override async Task UnaryServerHandler(TRequest request, ServerCallContext context, UnaryServerMethod continuation) 13 | { 14 | try 15 | { 16 | return await base.UnaryServerHandler(request, context, continuation); 17 | } 18 | catch (Exception ex) 19 | { 20 | var data = new Metadata(); 21 | data.Add("message", ex.Message); 22 | throw new RpcException(new Status(StatusCode.Unknown, "Unknon"), data); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/GrpcServerDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GrpcServerDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/GrpcServerDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4930", 7 | "sslPort": 44372 8 | } 9 | }, 10 | "profiles": { 11 | "GrpcServerDemo": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/GrpcServerDemo/Proto/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option csharp_namespace = "GrpcServices"; 4 | 5 | package GrpcServices; 6 | 7 | service OrderGrpc { 8 | rpc CreateOrder(CreateOrderCommand) returns (CreateOrderResult); 9 | } 10 | 11 | 12 | message CreateOrderCommand { 13 | string buyerId = 1; 14 | int32 productId = 2; 15 | double unitPrice = 3; 16 | double discount = 4; 17 | int32 units = 5; 18 | } 19 | 20 | message CreateOrderResult { 21 | int32 orderId = 1; 22 | } -------------------------------------------------------------------------------- /samples/GrpcServerDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/GrpcServerDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Kestrel": { 3 | "Endpoints": { 4 | "Http": { 5 | "Url": "http://+:5000" 6 | }, 7 | "Https": { 8 | "Url": "https://+:5001" 9 | }, 10 | "Http2": { 11 | "Url": "http://+:5002", 12 | "Protocols": "Http2" 13 | } 14 | }, 15 | "Certificates": { 16 | "Default": { 17 | "Path": "cer.pfx", 18 | "Password": "123456" 19 | } 20 | } 21 | }, 22 | "Logging": { 23 | "LogLevel": { 24 | "Default": "Information", 25 | "Microsoft": "Warning", 26 | "Microsoft.Hosting.Lifetime": "Information" 27 | } 28 | }, 29 | "AllowedHosts": "*" 30 | } 31 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/Clients/NamedOrderServiceClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | 7 | namespace HttpClientFactoryDemo.Clients 8 | { 9 | public class NamedOrderServiceClient 10 | { 11 | IHttpClientFactory _httpClientFactory; 12 | 13 | const string _clientName = "NamedOrderServiceClient"; //定义客户端名称 14 | 15 | public NamedOrderServiceClient(IHttpClientFactory httpClientFactory) 16 | { 17 | _httpClientFactory = httpClientFactory; 18 | } 19 | 20 | 21 | public async Task Get() 22 | { 23 | var client = _httpClientFactory.CreateClient(_clientName); //使用客户端名称获取客户端 24 | 25 | //使用client发起HTTP请求,这里使用相对路径来访问 26 | return await client.GetStringAsync("/OrderService"); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/Clients/OrderServiceClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | 7 | namespace HttpClientFactoryDemo.Clients 8 | { 9 | public class OrderServiceClient 10 | { 11 | IHttpClientFactory _httpClientFactory; 12 | 13 | public OrderServiceClient(IHttpClientFactory httpClientFactory) 14 | { 15 | _httpClientFactory = httpClientFactory; 16 | } 17 | 18 | 19 | public async Task Get() 20 | { 21 | var client = _httpClientFactory.CreateClient(); 22 | 23 | //使用client发起HTTP请求 24 | return await client.GetStringAsync("https://localhost:5003/OrderService"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/Clients/TypedOrderServiceClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Net.Http; 6 | namespace HttpClientFactoryDemo.Clients 7 | { 8 | public class TypedOrderServiceClient 9 | { 10 | HttpClient _client; 11 | public TypedOrderServiceClient(HttpClient client) 12 | { 13 | _client = client; 14 | } 15 | 16 | 17 | public async Task Get() 18 | { 19 | return await _client.GetStringAsync("/OrderService"); //这里使用相对路径来访问 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/DelegatingHandlers/RequestIdDelegatingHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace HttpClientFactoryDemo.DelegatingHandlers 9 | { 10 | public class RequestIdDelegatingHandler : DelegatingHandler 11 | { 12 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 13 | { 14 | //处理请求 15 | request.Headers.Add("x-guid", Guid.NewGuid().ToString()); 16 | 17 | var result = await base.SendAsync(request, cancellationToken); //调用内部handler 18 | 19 | //处理响应 20 | 21 | return result; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/HttpClientFactoryDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace HttpClientFactoryDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:4377", 8 | "sslPort": 44347 9 | } 10 | }, 11 | "profiles": { 12 | "HttpClientFactoryDemo": { 13 | "commandName": "Project", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/HttpClientFactoryDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information", 7 | "System.Net.Http.HttpClient.TypedOrderServiceClient": "Trace" 8 | } 9 | }, 10 | "AllowedHosts": "*" 11 | } 12 | -------------------------------------------------------------------------------- /samples/LoggingDemo/LoggingDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/LoggingDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace LoggingDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/LoggingDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:6599", 8 | "sslPort": 44390 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "LoggingDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/LoggingDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LoggingDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/LoggingDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/LoggingDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | }, 8 | "Console": { 9 | "IncludeScopes": true 10 | } 11 | }, 12 | "AllowedHosts": "*" 13 | } 14 | -------------------------------------------------------------------------------- /samples/LoggingScopeDemo/LoggingScopeDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Always 15 | true 16 | PreserveNewest 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /samples/LoggingScopeDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | }, 8 | "Console": { 9 | "IncludeScopes": true, 10 | "LogLevel": { 11 | "Default": "Information", 12 | "LoggingScopeDemo.Program": "Trace", 13 | "alogger": "Trace" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/LoggingSerilogDemo/LoggingSerilogDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /samples/LoggingSerilogDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:6651", 8 | "sslPort": 44342 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "LoggingSerilogDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/LoggingSerilogDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LoggingSerilogDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/LoggingSerilogDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "Serilog": { 10 | "MinimumLevel": { 11 | "Default": "Information", 12 | "Override": { 13 | "Microsoft": "Error", 14 | "System": "Information" 15 | } 16 | } 17 | }, 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /samples/LoggingSimpleDemo/LoggingSimpleDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | PreserveNewest 15 | true 16 | PreserveNewest 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /samples/LoggingSimpleDemo/OrderService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.Extensions.Logging; 5 | namespace LoggingSimpleDemo 6 | { 7 | public class OrderService 8 | { 9 | ILogger _logger; 10 | public OrderService(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void Show() 16 | { 17 | _logger.LogInformation("Show Time{time}", DateTime.Now); 18 | 19 | 20 | 21 | _logger.LogInformation($"Show Time{DateTime.Now}"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/LoggingSimpleDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | }, 8 | "Console": { 9 | "LogLevel": { 10 | "Default": "Information", 11 | "Program": "Trace", 12 | "alogger": "Information", 13 | "LoggingSimpleDemo.OrderService": "None" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/MediatorDemo/MediatorDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/MiddlewareDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/Middlewares/MyBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using MiddlewareDemo.Middlewares; 6 | namespace Microsoft.AspNetCore.Builder 7 | { 8 | public static class MyBuilderExtensions 9 | { 10 | public static IApplicationBuilder UseMyMiddleware(this IApplicationBuilder app) 11 | { 12 | return app.UseMiddleware(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/Middlewares/MyMiddleware.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace MiddlewareDemo.Middlewares 9 | { 10 | class MyMiddleware 11 | { 12 | RequestDelegate _next; 13 | ILogger _logger; 14 | public MyMiddleware(RequestDelegate next, ILogger logger) 15 | { 16 | _next = next; 17 | _logger = logger; 18 | } 19 | 20 | public async Task InvokeAsync(HttpContext context) 21 | { 22 | using (_logger.BeginScope("TraceIdentifier:{TraceIdentifier}", context.TraceIdentifier)) 23 | { 24 | _logger.LogDebug("开始执行"); 25 | 26 | await _next(context); 27 | 28 | _logger.LogDebug("执行结束"); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace MiddlewareDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:13729", 8 | "sslPort": 44378 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "MiddlewareDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/MiddlewareDemo/Startup.cs -------------------------------------------------------------------------------- /samples/MiddlewareDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MiddlewareDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/MiddlewareDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | }, 8 | "Console": { 9 | "IncludeScopes": true 10 | } 11 | }, 12 | "AllowedHosts": "*" 13 | } 14 | -------------------------------------------------------------------------------- /samples/OptionsDemo/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.Extensions.Logging; 7 | using OptionsDemo.Services; 8 | namespace OptionsDemo.Controllers 9 | { 10 | [ApiController] 11 | [Route("[controller]")] 12 | public class WeatherForecastController : ControllerBase 13 | { 14 | private static readonly string[] Summaries = new[] 15 | { 16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 17 | }; 18 | 19 | private readonly ILogger _logger; 20 | 21 | public WeatherForecastController(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | [HttpGet] 27 | public int Get([FromServices]IOrderService orderService) 28 | { 29 | Console.WriteLine($"orderService.ShowMaxOrderCount:{orderService.ShowMaxOrderCount()}"); 30 | return 1; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/OptionsDemo/OptionsDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/OptionsDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace OptionsDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/OptionsDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:17150", 8 | "sslPort": 44317 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "OptionsDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/OptionsDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/OptionsDemo/Startup.cs -------------------------------------------------------------------------------- /samples/OptionsDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OptionsDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/OptionsDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/OptionsDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "OrderService": { 11 | "MaxOrderCount": 200 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/RemoteSite/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace RemoteSite 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/RemoteSite/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:3296", 8 | "sslPort": 44342 9 | } 10 | }, 11 | "profiles": { 12 | "RemoteSite": { 13 | "commandName": "Project", 14 | "launchBrowser": true, 15 | "launchUrl": "OrderService", 16 | "applicationUrl": "https://localhost:5003;http://localhost:5002", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/RemoteSite/RemoteSite.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/RemoteSite/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RemoteSite 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/RemoteSite/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/RemoteSite/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/RoutingDemo/Constraints/MyRouteConstraint.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Routing; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace RoutingDemo.Constraints 9 | { 10 | public class MyRouteConstraint : IRouteConstraint 11 | { 12 | public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) 13 | { 14 | if (RouteDirection.IncomingRequest == routeDirection) 15 | { 16 | var v = values[routeKey]; 17 | if (long.TryParse(v.ToString(), out var value)) 18 | { 19 | return true; 20 | } 21 | } 22 | return false; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/RoutingDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace RoutingDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/RoutingDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:5898", 8 | "sslPort": 44314 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "RoutingDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "swagger", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/RoutingDemo/RoutingDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | true 6 | $(NoWarn);1591 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /samples/RoutingDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/RoutingDemo/Startup.cs -------------------------------------------------------------------------------- /samples/RoutingDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/RoutingDemo/WeatherForecast.cs -------------------------------------------------------------------------------- /samples/RoutingDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/RoutingDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/Shared/Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/StartupDemo/Program.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/StartupDemo/Program.cs -------------------------------------------------------------------------------- /samples/StartupDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:2826", 8 | "sslPort": 44305 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "StartupDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/StartupDemo/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/samples/StartupDemo/Startup.cs -------------------------------------------------------------------------------- /samples/StartupDemo/StartupDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/StartupDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace StartupDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/StartupDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/StartupDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace StaticFilesDemo 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:3026", 8 | "sslPort": 44348 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "StaticFilesDemo": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/StaticFilesDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | true 14 | PreserveNewest 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace StaticFilesDemo 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/file/page.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | page 6 | 7 | 8 |

page

9 | 10 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/wwwroot/a/a.js: -------------------------------------------------------------------------------- 1 | alert("a"); -------------------------------------------------------------------------------- /samples/StaticFilesDemo/wwwroot/a/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | /a/index 6 | 7 | 8 | 9 |

这是/a/index

10 | 11 | -------------------------------------------------------------------------------- /samples/StaticFilesDemo/wwwroot/app.js: -------------------------------------------------------------------------------- 1 | alert("index"); -------------------------------------------------------------------------------- /samples/StaticFilesDemo/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 静态首页 6 | 7 | 8 | 9 |

这是静态首页

10 | 11 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build 9 | WORKDIR /src 10 | COPY ["GeekTime.Gateway/GeekTime.Gateway.csproj", "GeekTime.Gateway/"] 11 | COPY ["NuGet.config","NuGet.config"] 12 | RUN dotnet restore "GeekTime.Gateway/GeekTime.Gateway.csproj" 13 | COPY . . 14 | WORKDIR "/src/GeekTime.Gateway" 15 | RUN dotnet build "GeekTime.Gateway.csproj" -c Release -o /app/build 16 | 17 | FROM build AS publish 18 | RUN dotnet publish "GeekTime.Gateway.csproj" -c Release -o /app/publish 19 | 20 | FROM base AS final 21 | WORKDIR /app 22 | COPY --from=publish /app/publish . 23 | ENTRYPOINT ["dotnet", "GeekTime.Gateway.dll"] -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/GeekTime.Gateway.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | b21b3fbd-1e8c-498a-9f93-4f8ed6390867 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GeekTime.Gateway 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureAppConfiguration(builder => { 22 | builder.AddJsonFile("ocelot.json", optional: false, reloadOnChange: true); 23 | }) 24 | .ConfigureWebHostDefaults(webBuilder => 25 | { 26 | webBuilder.UseStartup(); 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:13280", 7 | "sslPort": 44395 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "GeekTime.Gateway": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development", 23 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore" 24 | }, 25 | "applicationUrl": "https://localhost:5007;http://localhost:5006" 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/ocelot.json: -------------------------------------------------------------------------------- 1 | { 2 | "ReRoutes": [ 3 | { 4 | "DownstreamPathTemplate": "/api/{version}/{everything}", 5 | "DownstreamScheme": "http", 6 | "DownstreamHostAndPorts": [ 7 | { 8 | "Host": "localhost", 9 | "Port": 5004 10 | } 11 | ], 12 | "UpstreamPathTemplate": "/api/mobileAgg/{everything}", 13 | "UpstreamHttpMethod": [] 14 | }, 15 | { 16 | "DownstreamPathTemplate": "/api/{everything}", 17 | "DownstreamScheme": "http", 18 | "DownstreamHostAndPorts": [ 19 | { 20 | "Host": "localhost", 21 | "Port": 5000 22 | } 23 | ], 24 | "AuthenticationOptions": { 25 | "AuthenticationProviderKey": "Cookies", 26 | "AllowedScopes": [] 27 | }, 28 | "RouteClaimsRequirement": { 29 | "UserType": "Admin" 30 | }, 31 | "UpstreamPathTemplate": "/api/mobile/{everything}", 32 | "UpstreamHttpMethod": [] 33 | } 34 | 35 | ], 36 | "GlobalConfiguration": { 37 | "RequestIdKey": "OcRequestId", 38 | "AdministrationPath": "/administration" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Gateway/skyapm.json: -------------------------------------------------------------------------------- 1 | { 2 | "SkyWalking": { 3 | "ServiceName": "ssasspp", 4 | "Namespace": "", 5 | "HeaderVersions": [ 6 | "sw6" 7 | ], 8 | "Sampling": { 9 | "SamplePer3Secs": -1, 10 | "Percentage": -1.0 11 | }, 12 | "Logging": { 13 | "Level": "Information", 14 | "FilePath": "logs\\skyapm-{Date}.log" 15 | }, 16 | "Transport": { 17 | "Interval": 3000, 18 | "ProtocolVersion": "v6", 19 | "QueueSize": 30000, 20 | "BatchSize": 3000, 21 | "gRPC": { 22 | "Servers": "localhost:11800", 23 | "Timeout": 10000, 24 | "ConnectTimeout": 10000, 25 | "ReportTimeout": 600000 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Controllers/OrderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using GeekTime.Mobile.ApiAggregator.Services; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | namespace GeekTime.Mobile.ApiAggregator.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | [ApiController] 13 | public class OrderController : ControllerBase 14 | { 15 | IOrderService _orderService; 16 | GeekTime.Ordering.API.Grpc.OrderService.OrderServiceClient _client; 17 | public OrderController(IOrderService orderService, GeekTime.Ordering.API.Grpc.OrderService.OrderServiceClient client) 18 | { 19 | _orderService = orderService; 20 | _client = client; 21 | 22 | } 23 | 24 | [HttpGet] 25 | public ActionResult GetOrders([FromQuery]Ordering.API.Grpc.SearchRequest request) 26 | { 27 | //添加其它服务的调用; 28 | var data = _client.Search(request); 29 | return Ok(data.Orders); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Controllers/TestController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Authentication.JwtBearer; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | namespace GeekTime.Mobile.ApiAggregator.Controllers 11 | { 12 | [Route("api/[controller]/[action]")] 13 | [ApiController] 14 | public class TestController : ControllerBase 15 | { 16 | public IActionResult Abc() 17 | { 18 | return Content("GeekTime.Mobile.ApiAggregator"); 19 | } 20 | 21 | [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] 22 | public IActionResult Jwt() 23 | { 24 | return Content(User.FindFirst("Name").Value); 25 | } 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/ApiGateways/GeekTime.Mobile.ApiAggregator/Dockerfile -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GeekTime.Mobile.ApiAggregator 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Services/IOrderService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime.Mobile.ApiAggregator.Services 7 | { 8 | public interface IOrderService 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Services/OrderService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Net.Http; 6 | namespace GeekTime.Mobile.ApiAggregator.Services 7 | { 8 | public class OrderService : IOrderService 9 | { 10 | IHttpClientFactory _clientFactory; 11 | HttpClient _httpClient; 12 | public OrderService(HttpClient httpClient) 13 | { 14 | //_clientFactory = clientFactory; 15 | _httpClient = httpClient; 16 | 17 | } 18 | 19 | 20 | public void GetOrder() 21 | { 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Services/OrderServiceClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Net.Http; 6 | namespace GeekTime.Mobile.ApiAggregator.Services 7 | { 8 | public class OrderServiceClient 9 | { 10 | IHttpClientFactory _httpClientFactory; 11 | 12 | public OrderServiceClient(IHttpClientFactory httpClientFactory) 13 | { 14 | _httpClientFactory = httpClientFactory; 15 | } 16 | 17 | 18 | public async Task Get() 19 | { 20 | var client = _httpClientFactory.CreateClient(); 21 | 22 | //使用client发起HTTP请求 23 | await client.GetAsync("https://localhost:5001/api/orders"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/ApiGateways/GeekTime.Mobile.ApiAggregator/Startup.cs -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GeekTime.Mobile.ApiAggregator 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ServiceUrls": { 10 | "OrderingAPI": "https://localhost:5001" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ServiceUrls": { 10 | "OrderingAPI": "https://geektime-ordering-api" 11 | }, 12 | "AllowedHosts": "*", 13 | "SecurityKey": "aabbccddffskldjfklajskdlfjlas234234234" 14 | } 15 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.ApiAggregator/skyapm.json: -------------------------------------------------------------------------------- 1 | { 2 | "SkyWalking": { 3 | "ServiceName": "mobile-apiaggregator", 4 | "Namespace": "", 5 | "HeaderVersions": [ 6 | "sw6" 7 | ], 8 | "Sampling": { 9 | "SamplePer3Secs": -1, 10 | "Percentage": -1.0 11 | }, 12 | "Logging": { 13 | "Level": "Information", 14 | "FilePath": "logs\\skyapm-{Date}.log" 15 | }, 16 | "Transport": { 17 | "Interval": 3000, 18 | "ProtocolVersion": "v6", 19 | "QueueSize": 30000, 20 | "BatchSize": 3000, 21 | "gRPC": { 22 | "Servers": "localhost:11800", 23 | "Timeout": 10000, 24 | "ConnectTimeout": 10000, 25 | "ReportTimeout": 600000 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.Gateway/Controllers/BankAccountController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Authentication.JwtBearer; 8 | using Microsoft.AspNetCore.Authentication.Cookies; 9 | 10 | namespace GeekTime.Mobile.Gateway.Controllers 11 | { 12 | [ApiController] 13 | [Route("api/[controller]/[action]")] 14 | public class BankAccountController : Controller 15 | { 16 | [Authorize] 17 | public IActionResult Cookie() 18 | { 19 | return Content("bank account"); 20 | } 21 | 22 | [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] 23 | public IActionResult Jwt() 24 | { 25 | return Content(User.FindFirst("Name").Value); 26 | } 27 | 28 | 29 | [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + CookieAuthenticationDefaults.AuthenticationScheme)] 30 | public IActionResult AnyOne() 31 | { 32 | return Content(User.FindFirst("Name").Value); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.Gateway/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/ApiGateways/GeekTime.Mobile.Gateway/Dockerfile -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.Gateway/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/ApiGateways/GeekTime.Mobile.Gateway/Startup.cs -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.Gateway/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ApiGateways/GeekTime.Mobile.Gateway/skyapm.json: -------------------------------------------------------------------------------- 1 | { 2 | "SkyWalking": { 3 | "ServiceName": "mobile-gateway", 4 | "Namespace": "", 5 | "HeaderVersions": [ 6 | "sw6" 7 | ], 8 | "Sampling": { 9 | "SamplePer3Secs": -1, 10 | "Percentage": -1.0 11 | }, 12 | "Logging": { 13 | "Level": "Information", 14 | "FilePath": "logs\\skyapm-{Date}.log" 15 | }, 16 | "Transport": { 17 | "Interval": 3000, 18 | "ProtocolVersion": "v6", 19 | "QueueSize": 30000, 20 | "BatchSize": 3000, 21 | "gRPC": { 22 | "Servers": "localhost:11800", 23 | "Timeout": 10000, 24 | "ConnectTimeout": 10000, 25 | "ReportTimeout": 600000 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Monitor/GeekTime.HealthChecksHost/Controllers/ExportersController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Prometheus; 8 | using Metric = Prometheus.Metrics; 9 | namespace GeekTime.HealthChecksHost.Controllers 10 | { 11 | [Route("api/[controller]/[action]")] 12 | [ApiController] 13 | public class ExportersController : ControllerBase 14 | { 15 | [HttpGet] 16 | public async Task GetMetricsAsync() 17 | { 18 | var r = Metric.NewCustomRegistry(); 19 | MetricFactory f = Metric.WithCustomRegistry(r); 20 | r.AddBeforeCollectCallback(() => 21 | { 22 | f.CreateCounter("counter_v1", "").Inc(100); 23 | }); 24 | Response.ContentType = PrometheusConstants.ExporterContentType; 25 | Response.StatusCode = 200; 26 | await r.CollectAndExportAsTextAsync(Response.Body, HttpContext.RequestAborted); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Monitor/GeekTime.HealthChecksHost/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Monitor/GeekTime.HealthChecksHost/Dockerfile -------------------------------------------------------------------------------- /src/Monitor/GeekTime.HealthChecksHost/GeekTime.HealthChecksHost.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 453c9bff-8763-4e16-9c21-f5e79ec494da 6 | Linux 7 | ..\..\.. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Monitor/GeekTime.HealthChecksHost/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GeekTime.HealthChecksHost 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Monitor/GeekTime.HealthChecksHost/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:9904", 7 | "sslPort": 44389 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "GeekTime.HealthChecksHost": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "launchUrl": "healthchecks-ui", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Monitor/GeekTime.HealthChecksHost/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/GeekTime.BadSite.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GeekTime.BadSite.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GeekTime.BadSite 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:4052", 7 | "sslPort": 44375 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "GeekTime.BadSite": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/Home/Cors.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Cors"; 4 | } 5 | 6 |

Cors

7 |

8 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 | 10 | 11 |
12 | 13 | 14 | 15 |
16 | 19 | 20 | 攻击链接https://localhost:5003/Home/Login?returnUrl=https%3A%2F%2Flocalhost%3A5001%2FHome%2FLogin -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/Home/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |

Login

7 |
8 | 9 | 10 | 11 |
-------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using GeekTime.BadSite 2 | @using GeekTime.BadSite.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Trace", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Samples/GeekTime.BadSite/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.BadSite/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/GeekTime.GoodSite.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GeekTime.GoodSite.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Models/OrderModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime.GoodSite.Models 7 | { 8 | public class OrderModel 9 | { 10 | public long Id { get; set; } 11 | 12 | public DateTime Date { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GeekTime.GoodSite 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:16401", 7 | "sslPort": 44336 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "GeekTime.GoodSite": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "applicationUrl": "https://localhost:5003;http://localhost:5002", 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Samples/GeekTime.GoodSite/Startup.cs -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 |
10 | 11 | 12 | @Html.AntiForgeryToken() 13 | 14 |
-------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/Home/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |

Login

7 |
8 | 9 | 10 | 11 | @Html.AntiForgeryToken() 12 | 13 |
14 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/Home/Show.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Show"; 4 | } 5 | 6 |

Show

7 | @Html.Raw(ViewData["content"].ToString()) -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using GeekTime.GoodSite 2 | @using GeekTime.GoodSite.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Information", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "RedisCache": { 11 | "Configuration": "localhost:6379", 12 | "InstanceName": "GoodSite" 13 | }, 14 | "easycaching": { 15 | "redis": { 16 | "MaxRdSecond": 120, 17 | "EnableLogging": false, 18 | "LockMs": 5000, 19 | "SleepMs": 300, 20 | "dbconfig": { 21 | "Password": null, 22 | "IsSsl": false, 23 | "SslHost": null, 24 | "ConnectionTimeout": 5000, 25 | "AllowAdmin": true, 26 | "Endpoints": [ 27 | { 28 | "Host": "localhost", 29 | "Port": 6379 30 | } 31 | ], 32 | "Database": 0 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Samples/GeekTime.GoodSite/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /src/Samples/GeekTime.GoodSite/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Services/Identity/GeekTime.Identity.API/Dockerfile -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/GeekTime.Identity.API.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | cb6b9c05-a918-4b1e-92d3-02fb2a2645d1 6 | Linux 7 | ..\..\..\.. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace GeekTime.Identity.API 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:38819", 7 | "sslPort": 44333 8 | } 9 | }, 10 | "$schema": "http://json.schemastore.org/launchsettings.json", 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "GeekTime.Identity.API": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | }, 27 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 28 | }, 29 | "Docker": { 30 | "commandName": "Docker", 31 | "launchBrowser": true, 32 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast", 33 | "publishAllPorts": true, 34 | "useSSL": true 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GeekTime.Identity.API 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/Services/Identity/GeekTime.Identity.API/skyapm.json: -------------------------------------------------------------------------------- 1 | { 2 | "SkyWalking": { 3 | "ServiceName": "identity-api", 4 | "Namespace": "", 5 | "HeaderVersions": [ 6 | "sw6" 7 | ], 8 | "Sampling": { 9 | "SamplePer3Secs": -1, 10 | "Percentage": -1.0 11 | }, 12 | "Logging": { 13 | "Level": "Information", 14 | "FilePath": "logs\\skyapm-{Date}.log" 15 | }, 16 | "Transport": { 17 | "Interval": 3000, 18 | "ProtocolVersion": "v6", 19 | "QueueSize": 30000, 20 | "BatchSize": 3000, 21 | "gRPC": { 22 | "Servers": "localhost:11800", 23 | "Timeout": 10000, 24 | "ConnectTimeout": 10000, 25 | "ReportTimeout": 600000 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/Commands/CreateOrderCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using MediatR; 6 | 7 | namespace GeekTime.Ordering.API.Application.Commands 8 | { 9 | public class CreateOrderCommand : IRequest 10 | { 11 | 12 | //ublic CreateOrderCommand() { } 13 | public CreateOrderCommand(int itemCount) 14 | { 15 | ItemCount = itemCount; 16 | } 17 | 18 | public long ItemCount { get; private set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/DomainEventHandlers/OrderCreatedDomainEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using GeekTime.Domain; 7 | using GeekTime.Ordering.Domain.Events; 8 | using DotNetCore.CAP; 9 | using GeekTime.Ordering.API.Application.IntegrationEvents; 10 | 11 | namespace GeekTime.Ordering.API.Application.DomainEventHandlers 12 | { 13 | public class OrderCreatedDomainEventHandler : IDomainEventHandler 14 | { 15 | ICapPublisher _capPublisher; 16 | public OrderCreatedDomainEventHandler(ICapPublisher capPublisher) 17 | { 18 | _capPublisher = capPublisher; 19 | } 20 | 21 | public async Task Handle(OrderCreatedDomainEvent notification, CancellationToken cancellationToken) 22 | { 23 | await _capPublisher.PublishAsync("OrderCreated", new OrderCreatedIntegrationEvent(notification.Order.Id)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/IntegrationEvents/ISubscriberService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime.Ordering.API.Application.IntegrationEvents 7 | { 8 | public interface ISubscriberService 9 | { 10 | void OrderPaymentSucceeded(OrderPaymentSucceededIntegrationEvent @event); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/IntegrationEvents/OrderCreatedIntegrationEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime.Ordering.API.Application.IntegrationEvents 7 | { 8 | public class OrderCreatedIntegrationEvent 9 | { 10 | public OrderCreatedIntegrationEvent(long orderId) => OrderId = orderId; 11 | public long OrderId { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/IntegrationEvents/OrderPaymentSucceededIntegrationEvent.cs: -------------------------------------------------------------------------------- 1 | namespace GeekTime.Ordering.API.Application.IntegrationEvents 2 | { 3 | public class OrderPaymentSucceededIntegrationEvent 4 | { 5 | public OrderPaymentSucceededIntegrationEvent(long orderId) => OrderId = orderId; 6 | public long OrderId { get; } 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/IntegrationEvents/SubscriberService.cs: -------------------------------------------------------------------------------- 1 | using DotNetCore.CAP; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using MediatR; 7 | namespace GeekTime.Ordering.API.Application.IntegrationEvents 8 | { 9 | public class SubscriberService : ISubscriberService, ICapSubscribe 10 | { 11 | IMediator _mediator; 12 | public SubscriberService(IMediator mediator) 13 | { 14 | _mediator = mediator; 15 | } 16 | 17 | 18 | [CapSubscribe("OrderPaymentSucceeded")] 19 | public void OrderPaymentSucceeded(OrderPaymentSucceededIntegrationEvent @event) 20 | { 21 | //Do SomeThing 22 | } 23 | 24 | [CapSubscribe("OrderCreated")] 25 | public void OrderCreated(OrderCreatedIntegrationEvent @event) 26 | { 27 | 28 | 29 | 30 | 31 | //Do SomeThing 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/Queries/MyOrderQuery.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using MediatR; 6 | namespace GeekTime.Ordering.API.Application.Queries 7 | { 8 | public class MyOrderQuery : IRequest> 9 | { 10 | public string UserName { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Application/Queries/MyOrderQueryHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using MediatR; 7 | namespace GeekTime.Ordering.API.Application.Queries 8 | { 9 | public class MyOrderQueryHandler : IRequestHandler> 10 | { 11 | public Task> Handle(MyOrderQuery request, CancellationToken cancellationToken) 12 | { 13 | return Task.FromResult(new List() { DateTime.Now.ToString() }); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Services/Ordering/GeekTime.Ordering.API/Dockerfile -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Extensions/ApplicationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace GeekTime.Ordering.API.Extensions 2 | { 3 | public static class ApplicationBuilderExtensions 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Grpc/ordering.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | import "google/protobuf/wrappers.proto"; 3 | option csharp_namespace = "GeekTime.Ordering.API.Grpc"; 4 | 5 | 6 | service OrderService { 7 | 8 | rpc CreateOrder(CreateOrderCommand) returns (google.protobuf.Int64Value); 9 | 10 | rpc Search(SearchRequest) returns (SearchResponse); 11 | } 12 | 13 | 14 | message CreateOrderCommand{ 15 | int32 ItemCount = 1; 16 | } 17 | 18 | message Order { 19 | int64 Id = 1; 20 | int64 UserId = 2; 21 | string UserName = 3; 22 | Address Address = 4; 23 | string ItemCount = 5; 24 | } 25 | 26 | message Address{ 27 | string Street = 1; 28 | string City = 2; 29 | string ZipCode = 3; 30 | } 31 | 32 | 33 | message SearchRequest{ 34 | string UserName = 1; 35 | } 36 | 37 | message SearchResponse{ 38 | repeated string Orders = 1; 39 | } -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/Startup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/witskeeper/geektime/0db78282a8719919b055a077b631150c210d447e/src/Services/Ordering/GeekTime.Ordering.API/Startup.cs -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Kestrel": { 3 | "Endpoints": { 4 | "Http": { 5 | "Url": "http://+:5000" 6 | }, 7 | "Https": { 8 | "Url": "https://+:5001" 9 | }, 10 | "Http2": { 11 | "Url": "http://+:5002", 12 | "Protocols": "Http2" 13 | } 14 | } 15 | }, 16 | "Logging": { 17 | "LogLevel": { 18 | "Default": "Trace", 19 | "Microsoft": "Trace", 20 | "Microsoft.Hosting.Lifetime": "Trace" 21 | } 22 | }, 23 | "Serilog": { 24 | "MinimumLevel": { 25 | "Default": "Error", 26 | "Override": { 27 | "Microsoft": "Error", 28 | "System": "Error" 29 | } 30 | } 31 | }, 32 | "exceptionless": { 33 | "ApiKey": "PSaokqmXC8T4xgWal9I0atA8TlYG7Ytz65JvxAL3", 34 | "ServerUrl": "http://localhost:30012" 35 | }, 36 | "AllowedHosts": "*", 37 | "Mysql": "server=localhost;port=3306;user id=root;password=123456;database=geektime;charset=utf8mb4;ConnectionReset=false;", 38 | "RabbitMQ": { 39 | "HostName": "localhost", 40 | "UserName": "guest", 41 | "Password": "guest", 42 | "VirtualHost": "/", 43 | "ExchangeName": "geek_queue" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.API/skyapm.json: -------------------------------------------------------------------------------- 1 | { 2 | "SkyWalking": { 3 | "ServiceName": "ordering-api", 4 | "Namespace": "", 5 | "HeaderVersions": [ 6 | "sw6" 7 | ], 8 | "Sampling": { 9 | "SamplePer3Secs": -1, 10 | "Percentage": -1.0 11 | }, 12 | "Logging": { 13 | "Level": "Information", 14 | "FilePath": "logs\\skyapm-{Date}.log" 15 | }, 16 | "Transport": { 17 | "Interval": 3000, 18 | "ProtocolVersion": "v6", 19 | "QueueSize": 30000, 20 | "BatchSize": 3000, 21 | "gRPC": { 22 | "Servers": "localhost:11800", 23 | "Timeout": 10000, 24 | "ConnectTimeout": 10000, 25 | "ReportTimeout": 600000 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.BackgroundTasks/GeekTime.Ordering.BackgroundTasks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.BackgroundTasks/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GeekTime.Ordering.BackgroundTasks 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Domain/Events/OrderCreatedDomainEvent.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Domain; 2 | using GeekTime.Ordering.Domain.OrderAggregate; 3 | 4 | namespace GeekTime.Ordering.Domain.Events 5 | { 6 | public class OrderCreatedDomainEvent : IDomainEvent 7 | { 8 | public Order Order { get; private set; } 9 | public OrderCreatedDomainEvent(Order order) 10 | { 11 | this.Order = order; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Domain/GeekTime.Ordering.Domain.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Domain/OrderAggregate/Address.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Domain; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace GeekTime.Ordering.Domain.OrderAggregate 7 | { 8 | public class Address : ValueObject 9 | { 10 | public string Street { get; private set; } 11 | public string City { get; private set; } 12 | public string ZipCode { get; private set; } 13 | 14 | public Address() { } 15 | public Address(string street, string city, string zipcode) 16 | { 17 | Street = street; 18 | City = city; 19 | ZipCode = zipcode; 20 | } 21 | 22 | protected override IEnumerable GetAtomicValues() 23 | { 24 | // Using a yield return statement to return each element one at a time 25 | yield return Street; 26 | yield return City; 27 | yield return ZipCode; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Domain/OrderAggregate/Order.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Domain; 2 | using GeekTime.Ordering.Domain.Events; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace GeekTime.Ordering.Domain.OrderAggregate 8 | { 9 | public class Order : Entity, IAggregateRoot 10 | { 11 | public string UserId { get; private set; } 12 | 13 | public string UserName { get; private set; } 14 | 15 | public Address Address { get; private set; } 16 | 17 | public int ItemCount { get; private set; } 18 | 19 | protected Order() 20 | { } 21 | 22 | public Order(string userId, string userName, int itemCount, Address address) 23 | { 24 | this.UserId = userId; 25 | this.UserName = userName; 26 | this.Address = address; 27 | this.ItemCount = itemCount; 28 | 29 | this.AddDomainEvent(new OrderCreatedDomainEvent(this)); 30 | } 31 | 32 | 33 | public void ChangeAddress(Address address) 34 | { 35 | this.Address = address; 36 | //this.AddDomainEvent(new OrderAddressChangedDomainEvent(this)); 37 | } 38 | 39 | 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Infrastructure/EntityConfigurations/OrderEntityTypeConfiguration.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Ordering.Domain.OrderAggregate; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace GeekTime.Ordering.Infrastructure.EntityConfigurations 6 | { 7 | class OrderEntityTypeConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.HasKey(p => p.Id); 12 | builder.ToTable("order"); 13 | builder.Property(p => p.UserId).HasMaxLength(20); 14 | builder.Property(p => p.UserName).HasMaxLength(30); 15 | builder.OwnsOne(o => o.Address, a => 16 | { 17 | a.WithOwner(); 18 | a.Property(p => p.City).HasMaxLength(20); 19 | a.Property(p => p.Street).HasMaxLength(50); 20 | a.Property(p => p.ZipCode).HasMaxLength(10); 21 | }); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Infrastructure/GeekTime.Ordering.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Infrastructure/OrderingContext.cs: -------------------------------------------------------------------------------- 1 | using DotNetCore.CAP; 2 | using GeekTime.Infrastructure.Core; 3 | using GeekTime.Ordering.Domain.OrderAggregate; 4 | using GeekTime.Ordering.Infrastructure.EntityConfigurations; 5 | using MediatR; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace GeekTime.Ordering.Infrastructure 9 | { 10 | public class OrderingContext : EFContext 11 | { 12 | public OrderingContext(DbContextOptions options, IMediator mediator, ICapPublisher capBus) : base(options, mediator, capBus) 13 | { 14 | } 15 | 16 | public DbSet Orders { get; set; } 17 | 18 | protected override void OnModelCreating(ModelBuilder modelBuilder) 19 | { 20 | #region 注册领域模型与数据库的映射关系 21 | modelBuilder.ApplyConfiguration(new OrderEntityTypeConfiguration()); 22 | #endregion 23 | base.OnModelCreating(modelBuilder); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Infrastructure/OrderingContextTransactionBehavior.cs: -------------------------------------------------------------------------------- 1 | using DotNetCore.CAP; 2 | using GeekTime.Infrastructure.Core.Behaviors; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace GeekTime.Ordering.Infrastructure 9 | { 10 | public class OrderingContextTransactionBehavior : TransactionBehavior 11 | { 12 | public OrderingContextTransactionBehavior(OrderingContext dbContext, ILogger> logger) : base(dbContext, logger) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Infrastructure/Repositories/IOrderRepository.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Infrastructure.Core; 2 | using GeekTime.Ordering.Domain.OrderAggregate; 3 | 4 | namespace GeekTime.Ordering.Infrastructure.Repositories 5 | { 6 | public interface IOrderRepository : IRepository 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Services/Ordering/GeekTime.Ordering.Infrastructure/Repositories/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Infrastructure.Core; 2 | using GeekTime.Ordering.Domain.OrderAggregate; 3 | 4 | namespace GeekTime.Ordering.Infrastructure.Repositories 5 | { 6 | public class OrderRepository : Repository, IOrderRepository 7 | { 8 | public OrderRepository(OrderingContext context) : base(context) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Core/GeekTime.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | GeekTime 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Core/IKnownException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime 7 | { 8 | public interface IKnownException 9 | { 10 | string Message { get; } 11 | 12 | int ErrorCode { get; } 13 | 14 | object[] ErrorData { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Core/KnownException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime 7 | { 8 | public class KnownException : IKnownException 9 | { 10 | public string Message { get; private set; } 11 | 12 | public int ErrorCode { get; private set; } 13 | 14 | public object[] ErrorData { get; private set; } 15 | 16 | public readonly static IKnownException Unknown = new KnownException { Message = "未知错误", ErrorCode = 9999 }; 17 | 18 | public static IKnownException FromKnownException(IKnownException exception) 19 | { 20 | return new KnownException { Message = exception.Message, ErrorCode = exception.ErrorCode, ErrorData = exception.ErrorData }; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Domain.Abstractions/GeekTime.Domain.Abstractions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | GeekTime.Domain 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Domain.Abstractions/IAggregateRoot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace GeekTime.Domain 6 | { 7 | public interface IAggregateRoot 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Domain.Abstractions/IDomainEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using MediatR; 7 | namespace GeekTime.Domain 8 | { 9 | public interface IDomainEvent : INotification 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Domain.Abstractions/IDomainEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using MediatR; 7 | namespace GeekTime.Domain 8 | { 9 | public interface IDomainEventHandler : INotificationHandler 10 | where TDomainEvent : IDomainEvent 11 | { 12 | //这里我们使用了INotificationHandler的Handle方法来作为处理方法的定义 13 | //Task Handle(TDomainEvent domainEvent, CancellationToken cancellationToken); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Domain.Abstractions/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace GeekTime.Domain 6 | { 7 | public interface IEntity 8 | { 9 | object[] GetKeys(); 10 | } 11 | 12 | public interface IEntity : IEntity 13 | { 14 | TKey Id { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Extensions.Http/GeekTime.Extensions.Http.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Extensions.Http/HttpClientExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Newtonsoft.Json; 6 | namespace System.Net.Http 7 | { 8 | public static class HttpClientExtensions 9 | { 10 | public static async Task PostJsonAsync(this HttpClient httpClient, Uri requestUri, T data, CancellationToken cancellationToken) 11 | { 12 | var json = JsonConvert.SerializeObject(data); 13 | var content = new StringContent(json, Encoding.UTF8, "application/json"); 14 | return await httpClient.PostAsync(requestUri, content, cancellationToken); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Extensions.Http/HttpResponseMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Newtonsoft.Json; 6 | namespace System.Net.Http 7 | { 8 | public static class HttpResponseMessageExtensions 9 | { 10 | public async static Task AsJson(this HttpResponseMessage httpResponseMessage) 11 | { 12 | var json = await httpResponseMessage.Content.ReadAsStringAsync(); 13 | return JsonConvert.DeserializeObject(json); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Infrastructure.Core/Extensions/GenericTypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace GeekTime.Infrastructure.Core.Extensions 7 | { 8 | public static class GenericTypeExtensions 9 | { 10 | public static string GetGenericTypeName(this Type type) 11 | { 12 | var typeName = string.Empty; 13 | 14 | if (type.IsGenericType) 15 | { 16 | var genericTypes = string.Join(",", type.GetGenericArguments().Select(t => t.Name).ToArray()); 17 | typeName = $"{type.Name.Remove(type.Name.IndexOf('`'))}<{genericTypes}>"; 18 | } 19 | else 20 | { 21 | typeName = type.Name; 22 | } 23 | 24 | return typeName; 25 | } 26 | 27 | public static string GetGenericTypeName(this object @object) 28 | { 29 | return @object.GetType().GetGenericTypeName(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Infrastructure.Core/Extensions/MediatorExtension.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Domain; 2 | using MediatR; 3 | using Microsoft.EntityFrameworkCore; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace GeekTime.Infrastructure.Core.Extensions 8 | { 9 | static class MediatorExtension 10 | { 11 | public static async Task DispatchDomainEventsAsync(this IMediator mediator, DbContext ctx) 12 | { 13 | var domainEntities = ctx.ChangeTracker 14 | .Entries() 15 | .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any()); 16 | 17 | var domainEvents = domainEntities 18 | .SelectMany(x => x.Entity.DomainEvents) 19 | .ToList(); 20 | 21 | domainEntities.ToList() 22 | .ForEach(entity => entity.Entity.ClearDomainEvents()); 23 | 24 | foreach (var domainEvent in domainEvents) 25 | await mediator.Publish(domainEvent); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Infrastructure.Core/GeekTime.Infrastructure.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | GeekTime.Infrastructure.Core 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Infrastructure.Core/IRepository.cs: -------------------------------------------------------------------------------- 1 | using GeekTime.Domain; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace GeekTime.Infrastructure.Core 9 | { 10 | public interface IRepository where TEntity : Entity, IAggregateRoot 11 | { 12 | IUnitOfWork UnitOfWork { get; } 13 | TEntity Add(TEntity entity); 14 | Task AddAsync(TEntity entity, CancellationToken cancellationToken = default); 15 | TEntity Update(TEntity entity); 16 | Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default); 17 | bool Remove(Entity entity); 18 | Task RemoveAsync(Entity entity); 19 | } 20 | 21 | 22 | public interface IRepository : IRepository where TEntity : Entity, IAggregateRoot 23 | { 24 | bool Delete(TKey id); 25 | Task DeleteAsync(TKey id, CancellationToken cancellationToken = default); 26 | TEntity Get(TKey id); 27 | Task GetAsync(TKey id, CancellationToken cancellationToken = default); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Infrastructure.Core/ITransaction.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Storage; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace GeekTime.Infrastructure.Core 8 | { 9 | public interface ITransaction 10 | { 11 | IDbContextTransaction GetCurrentTransaction(); 12 | 13 | bool HasActiveTransaction { get; } 14 | 15 | Task BeginTransactionAsync(); 16 | 17 | Task CommitTransactionAsync(IDbContextTransaction transaction); 18 | 19 | void RollbackTransaction(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Shared/GeekTime.Infrastructure.Core/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace GeekTime.Infrastructure.Core 8 | { 9 | public interface IUnitOfWork : IDisposable 10 | { 11 | Task SaveChangesAsync(CancellationToken cancellationToken = default); 12 | Task SaveEntitiesAsync(CancellationToken cancellationToken = default); 13 | } 14 | } 15 | --------------------------------------------------------------------------------