├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── EurekaServiceProject ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── eurekaservice │ │ │ └── EurekaServiceProject │ │ │ └── EurekaServiceProjectApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── eurekaservice │ └── EurekaServiceProject │ └── EurekaServiceProjectApplicationTests.java ├── apigateway ├── .dockerignore ├── .gitignore ├── Controllers │ └── GatewayController.cs ├── Dockerfile ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── apigateway.csproj ├── appsettings.Development.json ├── appsettings.json ├── bin │ └── Debug │ │ └── netcoreapp2.1 │ │ ├── apigateway.deps.json │ │ ├── apigateway.dll │ │ ├── apigateway.pdb │ │ ├── apigateway.runtimeconfig.dev.json │ │ └── apigateway.runtimeconfig.json ├── nlog.config ├── obj │ ├── Debug │ │ └── netcoreapp2.1 │ │ │ ├── apigateway.AssemblyInfo.cs │ │ │ ├── apigateway.AssemblyInfoInputs.cache │ │ │ ├── apigateway.RazorAssemblyInfo.cache │ │ │ ├── apigateway.RazorAssemblyInfo.cs │ │ │ ├── apigateway.RazorTargetAssemblyInfo.cache │ │ │ ├── apigateway.assets.cache │ │ │ ├── apigateway.csproj.CoreCompileInputs.cache │ │ │ ├── apigateway.csproj.FileListAbsolute.txt │ │ │ ├── apigateway.csprojAssemblyReference.cache │ │ │ ├── apigateway.csprojResolveAssemblyReference.cache │ │ │ ├── apigateway.dll │ │ │ ├── apigateway.pdb │ │ │ └── project.razor.json │ ├── apigateway.csproj.nuget.cache │ ├── apigateway.csproj.nuget.g.props │ ├── apigateway.csproj.nuget.g.targets │ └── project.assets.json └── ocelot.json ├── authserver ├── .dockerignore ├── Controllers │ └── AuthController.cs ├── Dockerfile ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── appsettings.Development.json ├── appsettings.json ├── bin │ └── Debug │ │ └── netcoreapp2.1 │ │ ├── netmicroservice.deps.json │ │ ├── netmicroservice.dll │ │ ├── netmicroservice.pdb │ │ ├── netmicroservice.runtimeconfig.dev.json │ │ └── netmicroservice.runtimeconfig.json ├── netmicroservice.csproj └── obj │ ├── Debug │ └── netcoreapp2.1 │ │ ├── netmicroservice.AssemblyInfo.cs │ │ ├── netmicroservice.AssemblyInfoInputs.cache │ │ ├── netmicroservice.RazorAssemblyInfo.cache │ │ ├── netmicroservice.RazorAssemblyInfo.cs │ │ ├── netmicroservice.RazorTargetAssemblyInfo.cache │ │ ├── netmicroservice.assets.cache │ │ ├── netmicroservice.csproj.CoreCompileInputs.cache │ │ ├── netmicroservice.csproj.FileListAbsolute.txt │ │ ├── netmicroservice.csprojAssemblyReference.cache │ │ ├── netmicroservice.dll │ │ ├── netmicroservice.pdb │ │ └── project.razor.json │ ├── netmicroservice.csproj.nuget.cache │ ├── netmicroservice.csproj.nuget.g.props │ ├── netmicroservice.csproj.nuget.g.targets │ └── project.assets.json ├── configserver ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs ├── HELP.md ├── customer-service.yaml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── configserverproject │ │ │ └── ConfigServerProject │ │ │ └── ConfigServerProjectApplication.java │ │ └── resources │ │ └── application.yml └── target │ ├── classes │ ├── application.yml │ └── com │ │ └── configserverproject │ │ └── ConfigServerProject │ │ └── ConfigServerProjectApplication.class │ └── test-classes │ └── com │ └── configserverproject │ └── ConfigServerProject │ └── ConfigServerProjectApplicationTests.class ├── customer-service.yaml ├── customerapi ├── .dockerignore ├── Controllers │ └── CustomerController.cs ├── Dockerfile ├── Extensions │ └── WebApiClientExtension.cs ├── Interfaces │ └── IUserApiClient.cs ├── Model │ └── User.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── appsettings.Development.json ├── appsettings.json ├── bin │ └── Debug │ │ └── netcoreapp2.1 │ │ ├── customerapi.deps.json │ │ ├── customerapi.dll │ │ ├── customerapi.pdb │ │ ├── customerapi.runtimeconfig.dev.json │ │ └── customerapi.runtimeconfig.json ├── customerapi.csproj └── obj │ ├── Debug │ └── netcoreapp2.1 │ │ ├── customerapi.AssemblyInfo.cs │ │ ├── customerapi.AssemblyInfoInputs.cache │ │ ├── customerapi.RazorAssemblyInfo.cache │ │ ├── customerapi.RazorAssemblyInfo.cs │ │ ├── customerapi.RazorTargetAssemblyInfo.cache │ │ ├── customerapi.assets.cache │ │ ├── customerapi.csproj.CoreCompileInputs.cache │ │ ├── customerapi.csproj.FileListAbsolute.txt │ │ ├── customerapi.csprojAssemblyReference.cache │ │ ├── customerapi.dll │ │ ├── customerapi.pdb │ │ └── project.razor.json │ ├── customerapi.csproj.nuget.cache │ ├── customerapi.csproj.nuget.g.props │ ├── customerapi.csproj.nuget.g.targets │ └── project.assets.json ├── docker-compose.yml ├── productapi ├── .dockerignore ├── Controllers │ └── ProductController.cs ├── Dockerfile ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── appsettings.Development.json ├── appsettings.json ├── bin │ └── Debug │ │ └── netcoreapp2.1 │ │ ├── productapi.deps.json │ │ ├── productapi.dll │ │ ├── productapi.pdb │ │ ├── productapi.runtimeconfig.dev.json │ │ └── productapi.runtimeconfig.json ├── obj │ ├── Debug │ │ └── netcoreapp2.1 │ │ │ ├── productapi.AssemblyInfo.cs │ │ │ ├── productapi.AssemblyInfoInputs.cache │ │ │ ├── productapi.RazorAssemblyInfo.cache │ │ │ ├── productapi.RazorAssemblyInfo.cs │ │ │ ├── productapi.RazorTargetAssemblyInfo.cache │ │ │ ├── productapi.assets.cache │ │ │ ├── productapi.csproj.CoreCompileInputs.cache │ │ │ ├── productapi.csproj.FileListAbsolute.txt │ │ │ ├── productapi.csprojAssemblyReference.cache │ │ │ ├── productapi.csprojResolveAssemblyReference.cache │ │ │ ├── productapi.dll │ │ │ ├── productapi.pdb │ │ │ └── project.razor.json │ ├── productapi.csproj.nuget.cache │ ├── productapi.csproj.nuget.g.props │ ├── productapi.csproj.nuget.g.targets │ └── project.assets.json └── productapi.csproj └── userapi ├── Controllers └── UserController.cs ├── Program.cs ├── Properties └── launchSettings.json ├── Startup.cs ├── Util ├── EventBus.cs └── IEventBus.cs ├── appsettings.Development.json ├── appsettings.json └── userapi.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.*~ 3 | project.lock.json 4 | .DS_Store 5 | *.pyc 6 | nupkg/ 7 | 8 | # Visual Studio Code 9 | .vscode 10 | productapi/obj 11 | 12 | # Rider 13 | .idea 14 | 15 | # User-specific files 16 | *.suo 17 | *.user 18 | *.userosscache 19 | *.sln.docstates 20 | 21 | # Build results 22 | [Dd]ebug/ 23 | [Dd]ebugPublic/ 24 | [Rr]elease/ 25 | [Rr]eleases/ 26 | x64/ 27 | x86/ 28 | build/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | msbuild.log 34 | msbuild.err 35 | msbuild.wrn 36 | 37 | # Visual Studio 2015 38 | .vs/ 39 | apigateway/obj/Debug 40 | apigateway/bin 41 | apigateway/bin/Debug/netcoreapp2.1/apigateway.pdb 42 | apigateway/bin/Debug/netcoreapp2.1/apigateway.dll 43 | apigateway/bin/Debug/netcoreapp2.1/apigateway.deps.json 44 | apigateway/obj/apigateway.csproj.nuget.cache 45 | customerapi/bin/Debug/netcoreapp2.1/customerapi.dll 46 | apigateway/bin/Debug/netcoreapp2.1/apigateway.dll 47 | apigateway/bin/Debug/netcoreapp2.1/apigateway.pdb 48 | apigateway/bin/Debug/netcoreapp2.1/apigateway.deps.json 49 | apigateway/obj/apigateway.csproj.nuget.cache 50 | apigateway/obj/project.assets.json 51 | apigateway/obj/Debug/netcoreapp2.1/apigateway.dll 52 | apigateway/obj/Debug/netcoreapp2.1/apigateway.pdb 53 | apigateway/obj/Debug/netcoreapp2.1/apigateway.assets.cache 54 | apigateway/obj/Debug/netcoreapp2.1/apigateway.csproj.CoreCompileInputs.cache 55 | apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojAssemblyReference.cache 56 | customerapi/bin/Debug/netcoreapp2.1/customerapi.pdb 57 | customerapi/bin/Debug/netcoreapp2.1/customerapi.deps.json 58 | customerapi/obj/customerapi.csproj.nuget.cache 59 | customerapi/obj/project.assets.json 60 | customerapi/obj/Debug/netcoreapp2.1/customerapi.dll 61 | customerapi/obj/Debug/netcoreapp2.1/customerapi.pdb 62 | customerapi/obj/Debug/netcoreapp2.1/customerapi.assets.cache 63 | customerapi/obj/Debug/netcoreapp2.1/customerapi.csproj.CoreCompileInputs.cache 64 | customerapi/obj/Debug/netcoreapp2.1/customerapi.csprojAssemblyReference.cache 65 | authserver/obj/Debug/netcoreapp2.1/project.razor.json 66 | apigateway/bin/Debug/netcoreapp2.1/apigateway.deps.json 67 | apigateway/bin/Debug/netcoreapp2.1/apigateway.dll 68 | apigateway/bin/Debug/netcoreapp2.1/apigateway.pdb 69 | apigateway/obj/apigateway.csproj.nuget.cache 70 | apigateway/obj/project.assets.json 71 | apigateway/obj/Debug/netcoreapp2.1/apigateway.assets.cache 72 | apigateway/obj/Debug/netcoreapp2.1/apigateway.csproj.CoreCompileInputs.cache 73 | apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojAssemblyReference.cache 74 | apigateway/obj/Debug/netcoreapp2.1/apigateway.dll 75 | apigateway/obj/Debug/netcoreapp2.1/apigateway.pdb 76 | apigateway/obj/Debug/netcoreapp2.1/project.razor.json 77 | authserver/obj/Debug/netcoreapp2.1/netmicroservice.csprojAssemblyReference.cache 78 | customerapi/bin/Debug/netcoreapp2.1/customerapi.deps.json 79 | customerapi/bin/Debug/netcoreapp2.1/customerapi.dll 80 | customerapi/bin/Debug/netcoreapp2.1/customerapi.pdb 81 | customerapi/obj/customerapi.csproj.nuget.cache 82 | customerapi/obj/project.assets.json 83 | customerapi/obj/Debug/netcoreapp2.1/customerapi.assets.cache 84 | customerapi/obj/Debug/netcoreapp2.1/customerapi.csproj.CoreCompileInputs.cache 85 | customerapi/obj/Debug/netcoreapp2.1/customerapi.csprojAssemblyReference.cache 86 | customerapi/obj/Debug/netcoreapp2.1/customerapi.dll 87 | customerapi/obj/Debug/netcoreapp2.1/customerapi.pdb 88 | customerapi/obj/Debug/netcoreapp2.1/project.razor.json 89 | productapi/obj/Debug/netcoreapp2.1/project.razor.json 90 | apigateway/bin/Debug/netcoreapp2.1/apigateway.deps.json 91 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web) - Customer", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/customerapi/bin/Debug/netcoreapp2.1/customerapi.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}", 15 | "stopAtEntry": false, 16 | "launchBrowser": { 17 | "enabled": true 18 | }, 19 | "env": { 20 | "ASPNETCORE_ENVIRONMENT": "Development" 21 | }, 22 | "sourceFileMap": { 23 | "/Views": "${workspaceFolder}/Views" 24 | } 25 | }, 26 | { 27 | "name": ".NET Core Launch (web) - Auth Server", 28 | "type": "coreclr", 29 | "request": "launch", 30 | "preLaunchTask": "build", 31 | "program": "${workspaceFolder}/authserver/bin/Debug/netcoreapp2.1/netmicroservice.dll", 32 | "args": [], 33 | "cwd": "${workspaceFolder}", 34 | "stopAtEntry": false, 35 | "requireExactSource": false, 36 | "launchBrowser": { 37 | "enabled": true 38 | }, 39 | "env": { 40 | "ASPNETCORE_ENVIRONMENT": "Development" 41 | }, 42 | "sourceFileMap": { 43 | "/Views": "${workspaceFolder}/Views" 44 | } 45 | }, 46 | { 47 | "name": ".NET Core Launch (web)", 48 | "type": "coreclr", 49 | "request": "launch", 50 | "preLaunchTask": "build", 51 | "program": "${workspaceFolder}/apigateway/bin/Debug/netcoreapp2.1/apigateway.dll", 52 | "args": [], 53 | "cwd": "${workspaceFolder}/apigateway", 54 | "stopAtEntry": false, 55 | "launchBrowser": { 56 | "enabled": true 57 | }, 58 | "env": { 59 | "ASPNETCORE_ENVIRONMENT": "Development" 60 | }, 61 | "sourceFileMap": { 62 | "/Views": "${workspaceFolder}/Views" 63 | } 64 | }, 65 | { 66 | "name": ".NET Core Attach", 67 | "type": "coreclr", 68 | "request": "attach", 69 | "processId": "${command:pickProcess}" 70 | }, 71 | { 72 | "type": "java", 73 | "name": "Spring Boot-EurekaServiceProjectApplication", 74 | "request": "launch", 75 | "cwd": "${workspaceFolder}", 76 | "console": "internalConsole", 77 | "mainClass": "com.eurekaservice.EurekaServiceProject.EurekaServiceProjectApplication", 78 | "projectName": "EurekaServiceProject", 79 | "args": "" 80 | } 81 | ] 82 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/apigateway/apigateway.csproj" 11 | ], 12 | "problemMatcher": "$tsc" 13 | }, 14 | { 15 | "label": "publish", 16 | "command": "dotnet", 17 | "type": "process", 18 | "args": [ 19 | "publish", 20 | "${workspaceFolder}/apigateway/apigateway.csproj" 21 | ], 22 | "problemMatcher": "$tsc" 23 | }, 24 | { 25 | "label": "watch", 26 | "command": "dotnet", 27 | "type": "process", 28 | "args": [ 29 | "watch", 30 | "run", 31 | "${workspaceFolder}/apigateway/apigateway.csproj" 32 | ], 33 | "problemMatcher": "$tsc" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /EurekaServiceProject/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /EurekaServiceProject/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /EurekaServiceProject/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/EurekaServiceProject/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /EurekaServiceProject/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /EurekaServiceProject/Dockerfile: -------------------------------------------------------------------------------- 1 | # Start with a base image containing Java runtime 2 | FROM openjdk:8-jdk-alpine 3 | 4 | # Add Maintainer Info 5 | LABEL maintainer="abdulkerimkaraman@gmail.com" 6 | 7 | # Add a volume pointing to /tmp 8 | VOLUME /tmp 9 | 10 | # Make port 8080 available to the world outside this container 11 | EXPOSE 8761/tcp 12 | 13 | # The application's jar file 14 | ARG JAR_FILE=target/EurekaServiceProject-0.0.1-SNAPSHOT.jar 15 | 16 | # Add the application's jar to the container 17 | ADD ${JAR_FILE} EurekaServiceProject.jar 18 | 19 | # Run the jar file 20 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/EurekaServiceProject.jar"] -------------------------------------------------------------------------------- /EurekaServiceProject/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /EurekaServiceProject/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /EurekaServiceProject/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.3.RELEASE 9 | 10 | 11 | com.eurekaservice 12 | EurekaServiceProject 13 | 0.0.1-SNAPSHOT 14 | EurekaServiceProject 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | Greenwich.SR1 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-netflix-eureka-server 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | test 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-dependencies 40 | ${spring-cloud.version} 41 | pom 42 | import 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-maven-plugin 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /EurekaServiceProject/src/main/java/com/eurekaservice/EurekaServiceProject/EurekaServiceProjectApplication.java: -------------------------------------------------------------------------------- 1 | package com.eurekaservice.EurekaServiceProject; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaServiceProjectApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaServiceProjectApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /EurekaServiceProject/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8761 2 | eureka.client.service-url.defaultZone = http://localhost:8761/eureka 3 | 4 | eureka.client.register-with-eureka=false 5 | eureka.client.fetch-registry=false 6 | 7 | logging.level.com.netflix.eureka=OFF 8 | logging.level.caom.netflix.discovery=OFF 9 | -------------------------------------------------------------------------------- /EurekaServiceProject/src/test/java/com/eurekaservice/EurekaServiceProject/EurekaServiceProjectApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eurekaservice.EurekaServiceProject; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class EurekaServiceProjectApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /apigateway/.dockerignore: -------------------------------------------------------------------------------- 1 | bin\ 2 | obj\ -------------------------------------------------------------------------------- /apigateway/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.*~ 3 | project.lock.json 4 | .DS_Store 5 | *.pyc 6 | nupkg/ 7 | 8 | # Visual Studio Code 9 | .vscode 10 | 11 | # Rider 12 | .idea 13 | 14 | # User-specific files 15 | *.suo 16 | *.user 17 | *.userosscache 18 | *.sln.docstates 19 | 20 | # Build results 21 | [Dd]ebug/ 22 | [Dd]ebugPublic/ 23 | [Rr]elease/ 24 | [Rr]eleases/ 25 | x64/ 26 | x86/ 27 | build/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Oo]ut/ 32 | msbuild.log 33 | msbuild.err 34 | msbuild.wrn 35 | 36 | # Visual Studio 2015 37 | .vs/ -------------------------------------------------------------------------------- /apigateway/Controllers/GatewayController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace apigateway.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | [ApiController] 11 | public class GatewayController : ControllerBase 12 | { 13 | // GET api/values 14 | [HttpGet] 15 | public ActionResult> Get() 16 | { 17 | return new string[] { "value1", "value2" }; 18 | } 19 | 20 | // GET api/values/5 21 | [HttpGet("{id}")] 22 | public ActionResult Get(int id) 23 | { 24 | return "value"; 25 | } 26 | 27 | // POST api/values 28 | [HttpPost] 29 | public void Post([FromBody] string value) 30 | { 31 | } 32 | 33 | // PUT api/values/5 34 | [HttpPut("{id}")] 35 | public void Put(int id, [FromBody] string value) 36 | { 37 | } 38 | 39 | // DELETE api/values/5 40 | [HttpDelete("{id}")] 41 | public void Delete(int id) 42 | { 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /apigateway/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/dotnet:sdk AS build-env 2 | WORKDIR /app 3 | 4 | # Copy csproj and restore as distinct layers 5 | COPY *.csproj ./ 6 | RUN dotnet restore 7 | 8 | # Copy everything else and build 9 | COPY . ./ 10 | RUN dotnet publish -c Release -o out 11 | 12 | # Build runtime image 13 | FROM microsoft/dotnet:aspnetcore-runtime 14 | WORKDIR /app 15 | COPY --from=build-env /app/out . 16 | ENV ASPNETCORE_URLS http://*:7000 17 | ENV ASPNETCORE_ENVIRONMENT docker 18 | ENTRYPOINT ["dotnet", "apigateway.dll"] -------------------------------------------------------------------------------- /apigateway/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace apigateway 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .ConfigureAppConfiguration((host, config) => { 23 | config.AddJsonFile("ocelot.json"); 24 | }) 25 | .UseUrls("http://localhost:7000/") 26 | .UseStartup(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /apigateway/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:40843", 8 | "sslPort": 44394 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "apigateway": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/values", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /apigateway/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.HttpsPolicy; 9 | using Microsoft.AspNetCore.Mvc; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.Extensions.Logging; 13 | using Microsoft.Extensions.Options; 14 | using Microsoft.IdentityModel.Tokens; 15 | using NLog.Extensions.Logging; 16 | using Ocelot.DependencyInjection; 17 | using Ocelot.Middleware; 18 | using Ocelot.Provider.Eureka; 19 | 20 | namespace apigateway 21 | { 22 | public class Startup 23 | { 24 | public Startup(IConfiguration configuration) 25 | { 26 | Configuration = configuration; 27 | } 28 | 29 | public IConfiguration Configuration { get; } 30 | 31 | // This method gets called by the runtime. Use this method to add services to the container. 32 | public void ConfigureServices(IServiceCollection services) 33 | { 34 | var audienceConfig = Configuration.GetSection("Audience"); 35 | 36 | var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(audienceConfig["Secret"])); 37 | var tokenValidationParameters = new TokenValidationParameters 38 | { 39 | ValidateIssuerSigningKey = true, 40 | IssuerSigningKey = signingKey, 41 | ValidateIssuer = true, 42 | ValidIssuer = audienceConfig["Iss"], 43 | ValidateAudience = true, 44 | ValidAudience = audienceConfig["Aud"], 45 | ValidateLifetime = true, 46 | ClockSkew = TimeSpan.Zero, 47 | RequireExpirationTime = true, 48 | }; 49 | 50 | services.AddAuthentication(o => 51 | { 52 | o.DefaultAuthenticateScheme = "TestKey"; 53 | }); 54 | 55 | services.AddAuthentication() 56 | .AddJwtBearer("TestKey", x => 57 | { 58 | x.RequireHttpsMetadata = false; 59 | x.TokenValidationParameters = tokenValidationParameters; 60 | }); 61 | 62 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 63 | services.AddOcelot(Configuration).AddEureka(); 64 | } 65 | 66 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 67 | [Obsolete] 68 | public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 69 | { 70 | if (env.IsDevelopment()) 71 | { 72 | app.UseDeveloperExceptionPage(); 73 | } 74 | else 75 | { 76 | app.UseHsts(); 77 | } 78 | 79 | // -- Loging 80 | loggerFactory.AddNLog(); 81 | loggerFactory.ConfigureNLog("nlog.config"); 82 | loggerFactory.AddConsole(Configuration.GetSection("Logging")); 83 | app.UseOcelot().Wait(); 84 | // -- Loging 85 | 86 | var configuration = new OcelotPipelineConfiguration 87 | { 88 | PreQueryStringBuilderMiddleware = async (ctx, next) => 89 | { 90 | await next.Invoke(); 91 | } 92 | }; 93 | 94 | 95 | app.UseAuthentication(); // auth 96 | app.UseMvc(); 97 | await app.UseOcelot(configuration); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /apigateway/apigateway.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp2.1 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /apigateway/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /apigateway/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Audience": { 3 | "Secret": "Y2F0Y2hlciUyMHdvbmclMjBsb3ZlJTIwLm5ldA==", 4 | "Iss": "localhost", 5 | "Aud": "Abdulkerim Karaman" 6 | }, 7 | "spring": { 8 | "application": { 9 | "name": "apigateway" 10 | } 11 | }, 12 | "eureka": { 13 | "client": { 14 | "serviceUrl": "http://localhost:8761/eureka/", 15 | "shouldFetchRegistry": true, 16 | "validateCertificates": false 17 | }, 18 | "instance": { 19 | "port": 7000, 20 | "instanceId": "http://localhost:7000", 21 | "hostName": "localhost" 22 | } 23 | }, 24 | "Logging": { 25 | "IncludeScopes": true, 26 | "LogLevel": { 27 | "Default": "Trace", 28 | "System": "Information", 29 | "Microsoft": "Information" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /apigateway/bin/Debug/netcoreapp2.1/apigateway.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/bin/Debug/netcoreapp2.1/apigateway.dll -------------------------------------------------------------------------------- /apigateway/bin/Debug/netcoreapp2.1/apigateway.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/bin/Debug/netcoreapp2.1/apigateway.pdb -------------------------------------------------------------------------------- /apigateway/bin/Debug/netcoreapp2.1/apigateway.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "/Users/akaraman/.dotnet/store/|arch|/|tfm|", 5 | "/Users/akaraman/.nuget/packages", 6 | "/usr/local/share/dotnet/sdk/NuGetFallbackFolder" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /apigateway/bin/Debug/netcoreapp2.1/apigateway.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "netcoreapp2.1", 4 | "framework": { 5 | "name": "Microsoft.AspNetCore.App", 6 | "version": "2.1.1" 7 | }, 8 | "configProperties": { 9 | "System.GC.Server": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /apigateway/nlog.config: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Generated by the MSBuild WriteCodeFragment class. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Reflection; 9 | 10 | [assembly: System.Reflection.AssemblyCompanyAttribute("apigateway")] 11 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 12 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 13 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 14 | [assembly: System.Reflection.AssemblyProductAttribute("apigateway")] 15 | [assembly: System.Reflection.AssemblyTitleAttribute("apigateway")] 16 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 17 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 3688d67015d81ea15e187d6d260ff77f8b1a7cc8 2 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.RazorAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | 5859444fa8178a38b03bdb9e28356a9741c4ddc9 2 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.RazorAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Generated by the MSBuild WriteCodeFragment class. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Reflection; 9 | 10 | [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("apigateway.Views")] 11 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")] 12 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")] 13 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")] 14 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.RazorTargetAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | deeaa6b79c6b2d59b636649ad3ed265705e20b1b 2 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/obj/Debug/netcoreapp2.1/apigateway.assets.cache -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 5f69e22063f57a08875434f5c6045a4a8449aba7 2 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | /Users/akaraman/MyProjects/netmicroservice/apigateway/bin/Debug/netcoreapp2.1/apigateway.deps.json 2 | /Users/akaraman/MyProjects/netmicroservice/apigateway/bin/Debug/netcoreapp2.1/apigateway.runtimeconfig.json 3 | /Users/akaraman/MyProjects/netmicroservice/apigateway/bin/Debug/netcoreapp2.1/apigateway.runtimeconfig.dev.json 4 | /Users/akaraman/MyProjects/netmicroservice/apigateway/bin/Debug/netcoreapp2.1/apigateway.dll 5 | /Users/akaraman/MyProjects/netmicroservice/apigateway/bin/Debug/netcoreapp2.1/apigateway.pdb 6 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojAssemblyReference.cache 7 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.csproj.CoreCompileInputs.cache 8 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.RazorAssemblyInfo.cache 9 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.RazorAssemblyInfo.cs 10 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.AssemblyInfoInputs.cache 11 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.AssemblyInfo.cs 12 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.RazorTargetAssemblyInfo.cache 13 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.dll 14 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/Debug/netcoreapp2.1/apigateway.pdb 15 | -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/obj/Debug/netcoreapp2.1/apigateway.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/obj/Debug/netcoreapp2.1/apigateway.dll -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/apigateway.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/apigateway/obj/Debug/netcoreapp2.1/apigateway.pdb -------------------------------------------------------------------------------- /apigateway/obj/Debug/netcoreapp2.1/project.razor.json: -------------------------------------------------------------------------------- 1 | { 2 | "FilePath": "/Users/akaraman/MyProjects/netmicroservice/apigateway/apigateway.csproj", 3 | "Configuration": { 4 | "ConfigurationName": "MVC-2.1", 5 | "LanguageVersion": "2.1", 6 | "Extensions": [ 7 | { 8 | "ExtensionName": "MVC-2.1" 9 | } 10 | ] 11 | }, 12 | "ProjectWorkspaceState": null, 13 | "RootNamespace": "apigateway", 14 | "Documents": [], 15 | "SerializationFormat": "0.1" 16 | } -------------------------------------------------------------------------------- /apigateway/obj/apigateway.csproj.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dgSpecHash": "5pa39/SaqO6foCc4hqCdJioweByHhAYwZYExnhBPJNk4l9EnkNxvg94EKL1U+dJK62iHzS+vFmGNyMsJyHar2Q==", 4 | "success": true 5 | } -------------------------------------------------------------------------------- /apigateway/obj/apigateway.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | /Users/akaraman/MyProjects/netmicroservice/apigateway/obj/project.assets.json 7 | /Users/akaraman/.nuget/packages/ 8 | /Users/akaraman/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder 9 | PackageReference 10 | 4.8.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /apigateway/obj/apigateway.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /apigateway/ocelot.json: -------------------------------------------------------------------------------- 1 | { 2 | "ReRoutes": [ 3 | { 4 | "DownstreamPathTemplate": "/api/{everything}", 5 | "DownstreamScheme": "http", 6 | "UseServiceDiscovery": true, 7 | "ServiceName": "customer-service", 8 | "UpstreamPathTemplate": "/customer-service/{everything}", 9 | "UpstreamHttpMethod": [ "Get" ], 10 | "AuthenticationOptions": { 11 | "AuthenticationProviderKey": "TestKey", 12 | "AllowedScopes": [] 13 | } 14 | }, 15 | { 16 | "DownstreamPathTemplate": "/api/{everything}", 17 | "DownstreamScheme": "http", 18 | "UseServiceDiscovery": true, 19 | "ServiceName": "product-service", 20 | "UpstreamPathTemplate": "/product-service/{everything}", 21 | "UpstreamHttpMethod": [ "Get" ], 22 | "AuthenticationOptions": { 23 | "AuthenticationProviderKey": "TestKey", 24 | "AllowedScopes": [] 25 | } 26 | } 27 | ], 28 | "GlobalConfiguration": { 29 | "ServiceDiscoveryProvider": { 30 | "Type": "Eureka" 31 | }, 32 | "BaseUrl": "http://localhost:7000" 33 | } 34 | } -------------------------------------------------------------------------------- /authserver/.dockerignore: -------------------------------------------------------------------------------- 1 | obj\ 2 | bin\ -------------------------------------------------------------------------------- /authserver/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IdentityModel.Tokens.Jwt; 4 | using System.Linq; 5 | using System.Security.Claims; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Options; 10 | using Microsoft.IdentityModel.Tokens; 11 | 12 | namespace netmicroservice.Controllers 13 | { 14 | [Route("api/[controller]")] 15 | [ApiController] 16 | public class AuthController : Controller 17 | { 18 | 19 | 20 | [HttpGet] 21 | public IActionResult Get(string name, string pwd) 22 | { 23 | if (name == "testuser" && pwd == "123456") 24 | { 25 | var now = DateTime.UtcNow; 26 | 27 | var claims = new Claim[] 28 | { 29 | new Claim(JwtRegisteredClaimNames.Sub, name), 30 | new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), 31 | new Claim(JwtRegisteredClaimNames.Iat, now.ToUniversalTime().ToString(), ClaimValueTypes.Integer64) 32 | }; 33 | 34 | var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("Y2F0Y2hlciUyMHdvbmclMjBsb3ZlJTIwLm5ldA==")); 35 | var tokenValidationParameters = new TokenValidationParameters 36 | { 37 | ValidateIssuerSigningKey = true, 38 | IssuerSigningKey = signingKey, 39 | ValidateIssuer = true, 40 | ValidIssuer = "localhost", 41 | ValidateAudience = true, 42 | ValidAudience = "Abdulkerim Karaman", 43 | ValidateLifetime = true, 44 | ClockSkew = TimeSpan.Zero, 45 | RequireExpirationTime = true, 46 | 47 | }; 48 | 49 | var jwt = new JwtSecurityToken( 50 | issuer: "localhost", 51 | audience: "Abdulkerim Karaman", 52 | claims: claims, 53 | notBefore: now, 54 | expires: now.Add(TimeSpan.FromMinutes(500)), 55 | signingCredentials: new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256) 56 | ); 57 | var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt); 58 | var responseJson = new 59 | { 60 | access_token = encodedJwt, 61 | expires_in = (int)TimeSpan.FromMinutes(5000).TotalSeconds 62 | }; 63 | 64 | return Json(responseJson); 65 | } 66 | else 67 | { 68 | return Json(""); 69 | } 70 | } 71 | 72 | public class Audience 73 | { 74 | public string Secret { get; set; } 75 | public string Iss { get; set; } 76 | public string Aud { get; set; } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /authserver/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/dotnet:sdk AS build-env 2 | WORKDIR /app 3 | 4 | # Copy csproj and restore as distinct layers 5 | COPY *.csproj ./ 6 | RUN dotnet restore 7 | 8 | # Copy everything else and build 9 | COPY . ./ 10 | RUN dotnet publish -c Release -o out 11 | 12 | # Build runtime image 13 | FROM microsoft/dotnet:aspnetcore-runtime 14 | WORKDIR /app 15 | COPY --from=build-env /app/out . 16 | ENV ASPNETCORE_URLS http://*:5000 17 | ENV ASPNETCORE_ENVIRONMENT docker 18 | ENTRYPOINT ["dotnet", "netmicroservice.dll"] -------------------------------------------------------------------------------- /authserver/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace netmicroservice 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /authserver/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:55846", 8 | "sslPort": 44368 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "netmicroservice": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/values", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /authserver/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.Extensions.Options; 13 | 14 | namespace netmicroservice 15 | { 16 | public class Startup 17 | { 18 | public Startup(IConfiguration configuration) 19 | { 20 | Configuration = configuration; 21 | } 22 | 23 | public IConfiguration Configuration { get; } 24 | 25 | public void ConfigureServices(IServiceCollection services) 26 | { 27 | services.AddOptions(); 28 | services.Configure(Configuration.GetSection("Audience")); 29 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 30 | } 31 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 32 | { 33 | app.UseAuthentication(); 34 | if (env.IsDevelopment()) 35 | { 36 | app.UseDeveloperExceptionPage(); 37 | } 38 | else 39 | { 40 | app.UseHsts(); 41 | } 42 | app.UseMvc(); 43 | } 44 | } 45 | 46 | public class Audience 47 | { 48 | public string Secret { get; set; } 49 | public string Iss { get; set; } 50 | public string Aud { get; set; } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /authserver/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /authserver/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Audience": { 3 | "Secret": "Y2F0Y2hlciUyMHdvbmclMjBsb3ZlJTIwLm5ldA==", 4 | "Iss": "localhost", 5 | "Aud": "Abdulkerim Karaman" 6 | } 7 | } -------------------------------------------------------------------------------- /authserver/bin/Debug/netcoreapp2.1/netmicroservice.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/authserver/bin/Debug/netcoreapp2.1/netmicroservice.dll -------------------------------------------------------------------------------- /authserver/bin/Debug/netcoreapp2.1/netmicroservice.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/authserver/bin/Debug/netcoreapp2.1/netmicroservice.pdb -------------------------------------------------------------------------------- /authserver/bin/Debug/netcoreapp2.1/netmicroservice.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "/Users/akaraman/.dotnet/store/|arch|/|tfm|", 5 | "/Users/akaraman/.nuget/packages", 6 | "/usr/local/share/dotnet/sdk/NuGetFallbackFolder" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /authserver/bin/Debug/netcoreapp2.1/netmicroservice.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "netcoreapp2.1", 4 | "framework": { 5 | "name": "Microsoft.AspNetCore.App", 6 | "version": "2.1.1" 7 | }, 8 | "configProperties": { 9 | "System.GC.Server": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /authserver/netmicroservice.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Generated by the MSBuild WriteCodeFragment class. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Reflection; 9 | 10 | [assembly: System.Reflection.AssemblyCompanyAttribute("netmicroservice")] 11 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 12 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 13 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 14 | [assembly: System.Reflection.AssemblyProductAttribute("netmicroservice")] 15 | [assembly: System.Reflection.AssemblyTitleAttribute("netmicroservice")] 16 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 17 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 0e06eae83f47397079e77d0dc8c79a190c990113 2 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.RazorAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | c2bd6186ae8cf2740fe689bc06111215b2efc619 2 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.RazorAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Generated by the MSBuild WriteCodeFragment class. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Reflection; 9 | 10 | [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("netmicroservice.Views")] 11 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")] 12 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")] 13 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")] 14 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.RazorTargetAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | 3a5fcf4066e7e461ebe48958168c26cefeb49e02 2 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/authserver/obj/Debug/netcoreapp2.1/netmicroservice.assets.cache -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | d91b36001d4fbcfa57e29e8bac5cbe8fc37a68ea 2 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | /Users/akaraman/MyProjects/netmicroservice/authserver/bin/Debug/netcoreapp2.1/netmicroservice.deps.json 2 | /Users/akaraman/MyProjects/netmicroservice/authserver/bin/Debug/netcoreapp2.1/netmicroservice.runtimeconfig.json 3 | /Users/akaraman/MyProjects/netmicroservice/authserver/bin/Debug/netcoreapp2.1/netmicroservice.runtimeconfig.dev.json 4 | /Users/akaraman/MyProjects/netmicroservice/authserver/bin/Debug/netcoreapp2.1/netmicroservice.dll 5 | /Users/akaraman/MyProjects/netmicroservice/authserver/bin/Debug/netcoreapp2.1/netmicroservice.pdb 6 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.csprojAssemblyReference.cache 7 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.csproj.CoreCompileInputs.cache 8 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.RazorAssemblyInfo.cache 9 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.RazorAssemblyInfo.cs 10 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.AssemblyInfoInputs.cache 11 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.AssemblyInfo.cs 12 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.RazorTargetAssemblyInfo.cache 13 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.dll 14 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/Debug/netcoreapp2.1/netmicroservice.pdb 15 | -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/authserver/obj/Debug/netcoreapp2.1/netmicroservice.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/authserver/obj/Debug/netcoreapp2.1/netmicroservice.dll -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/netmicroservice.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/authserver/obj/Debug/netcoreapp2.1/netmicroservice.pdb -------------------------------------------------------------------------------- /authserver/obj/Debug/netcoreapp2.1/project.razor.json: -------------------------------------------------------------------------------- 1 | { 2 | "FilePath": "/Users/akaraman/MyProjects/netmicroservice/authserver/netmicroservice.csproj", 3 | "Configuration": { 4 | "ConfigurationName": "MVC-2.1", 5 | "LanguageVersion": "2.1", 6 | "Extensions": [ 7 | { 8 | "ExtensionName": "MVC-2.1" 9 | } 10 | ] 11 | }, 12 | "ProjectWorkspaceState": null, 13 | "RootNamespace": "netmicroservice", 14 | "Documents": [], 15 | "SerializationFormat": "0.1" 16 | } -------------------------------------------------------------------------------- /authserver/obj/netmicroservice.csproj.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dgSpecHash": "YOB15Nb0E+u2ewpVtaDQJJNLAoVvNFYL7xeeslRueG1P/bBBnvulAHS5N3QwK0F8VpwwVwwMAZUhCzk5BbRuHw==", 4 | "success": true 5 | } -------------------------------------------------------------------------------- /authserver/obj/netmicroservice.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | /Users/akaraman/MyProjects/netmicroservice/authserver/obj/project.assets.json 7 | /Users/akaraman/.nuget/packages/ 8 | /Users/akaraman/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder 9 | PackageReference 10 | 4.8.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /authserver/obj/netmicroservice.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /configserver/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /configserver/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ConfigServerProject 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.core.springbuilder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.ide.eclipse.core.springnature 31 | org.eclipse.jdt.core.javanature 32 | org.eclipse.m2e.core.maven2Nature 33 | 34 | 35 | -------------------------------------------------------------------------------- /configserver/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /configserver/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /configserver/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 9 | org.eclipse.jdt.core.compiler.release=disabled 10 | org.eclipse.jdt.core.compiler.source=1.8 11 | -------------------------------------------------------------------------------- /configserver/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /configserver/HELP.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ### Reference Documentation 4 | For further reference, please consider the following sections: 5 | 6 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) 7 | * [Spring Security](https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#boot-features-security) 8 | 9 | ### Guides 10 | The following guides illustrate how to use some features concretely: 11 | 12 | * [Centralized Configuration](https://spring.io/guides/gs/centralized-configuration/) 13 | * [Securing a Web Application](https://spring.io/guides/gs/securing-web/) 14 | * [Spring Boot and OAuth2](https://spring.io/guides/tutorials/spring-boot-oauth2/) 15 | * [Authenticating a User with LDAP](https://spring.io/guides/gs/authenticating-ldap/) 16 | 17 | -------------------------------------------------------------------------------- /configserver/customer-service.yaml: -------------------------------------------------------------------------------- 1 | user_service_url=https://jsonplaceholder.typicode.com -------------------------------------------------------------------------------- /configserver/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /configserver/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /configserver/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.4.RELEASE 9 | 10 | 11 | com.configserverproject 12 | ConfigServerProject 13 | 0.0.1-SNAPSHOT 14 | ConfigServerProject 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | Greenwich.SR2 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-config-server 26 | 27 | 28 | org.springframework.security 29 | spring-security-test 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-actuator 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.cloud 41 | spring-cloud-dependencies 42 | ${spring-cloud.version} 43 | pom 44 | import 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-maven-plugin 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /configserver/src/main/java/com/configserverproject/ConfigServerProject/ConfigServerProjectApplication.java: -------------------------------------------------------------------------------- 1 | package com.configserverproject.ConfigServerProject; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerProjectApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerProjectApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /configserver/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8980 3 | spring: 4 | application: 5 | name: config-server 6 | cloud: 7 | config: 8 | server: 9 | git: 10 | uri: https://github.com/akaramanapp/microservice-ocelot 11 | profiles: 12 | active: native 13 | management: 14 | security: 15 | enabled: false -------------------------------------------------------------------------------- /configserver/target/classes/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8980 3 | spring: 4 | application: 5 | name: config-server 6 | cloud: 7 | config: 8 | server: 9 | git: 10 | uri: https://github.com/akaramanapp/microservice-ocelot 11 | profiles: 12 | active: native 13 | management: 14 | security: 15 | enabled: false -------------------------------------------------------------------------------- /configserver/target/classes/com/configserverproject/ConfigServerProject/ConfigServerProjectApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/configserver/target/classes/com/configserverproject/ConfigServerProject/ConfigServerProjectApplication.class -------------------------------------------------------------------------------- /configserver/target/test-classes/com/configserverproject/ConfigServerProject/ConfigServerProjectApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/configserver/target/test-classes/com/configserverproject/ConfigServerProject/ConfigServerProjectApplicationTests.class -------------------------------------------------------------------------------- /customer-service.yaml: -------------------------------------------------------------------------------- 1 | user_service_url=https://jsonplaceholder.typicode.com 2 | -------------------------------------------------------------------------------- /customerapi/.dockerignore: -------------------------------------------------------------------------------- 1 | obj\ 2 | bin\ 3 | -------------------------------------------------------------------------------- /customerapi/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using Microsoft.AspNetCore.Authorization; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.Options; 7 | using Newtonsoft.Json; 8 | using static customerapi.Startup; 9 | 10 | namespace customerapi.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CustomerController : ControllerBase 15 | { 16 | private readonly IUserApiClient _api; 17 | 18 | private readonly IConfiguration _config; 19 | 20 | private readonly FetcherOptions _opt; 21 | 22 | public CustomerController(IConfiguration configuration, IOptions opt, IUserApiClient api) 23 | { 24 | this._api = api; 25 | this._config = configuration; 26 | 27 | this._opt = opt.Value; 28 | 29 | } 30 | // GET api/Customer 31 | //[Authorize] 32 | [HttpGet] 33 | public async Task> GetAsync() 34 | { 35 | return await _api.GetUsersAsync(); 36 | } 37 | 38 | // GET api/values/5 39 | [HttpGet("{id}")] 40 | public ActionResult Get(int id) 41 | { 42 | return "value"; 43 | } 44 | 45 | // POST api/values 46 | [HttpPost] 47 | public void Post([FromBody] string value) 48 | { 49 | } 50 | 51 | // PUT api/values/5 52 | [HttpPut("{id}")] 53 | public void Put(int id, [FromBody] string value) 54 | { 55 | } 56 | 57 | // DELETE api/values/5 58 | [HttpDelete("{id}")] 59 | public void Delete(int id) 60 | { 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /customerapi/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/dotnet:sdk AS build-env 2 | WORKDIR /app 3 | 4 | # Copy csproj and restore as distinct layers 5 | COPY *.csproj ./ 6 | RUN dotnet restore 7 | 8 | # Copy everything else and build 9 | COPY . ./ 10 | RUN dotnet publish -c Release -o out 11 | 12 | # Build runtime image 13 | FROM microsoft/dotnet:aspnetcore-runtime 14 | WORKDIR /app 15 | COPY --from=build-env /app/out . 16 | ENV ASPNETCORE_URLS http://*:7001 17 | ENV ASPNETCORE_ENVIRONMENT docker 18 | ENTRYPOINT ["dotnet", "customerapi.dll"] -------------------------------------------------------------------------------- /customerapi/Extensions/WebApiClientExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using WebApiClient; 4 | 5 | /// 6 | /// WebApiClient extension. 7 | /// 8 | public static class WebApiClientExtension 9 | { 10 | /// 11 | /// Adds the http API client. 12 | /// 13 | /// The http API client. 14 | /// Services. 15 | /// Config. 16 | /// The 1st type parameter. 17 | public static IHttpClientBuilder AddHttpApiClient(this IServiceCollection services, Action config = null) where TInterface : class, IHttpApi 18 | { 19 | return services.AddHttpClient(typeof(TInterface).Name).AddTypedClient((client, provider) => 20 | { 21 | var httpApiConfig = new HttpApiConfig(client); 22 | config?.Invoke(httpApiConfig); 23 | return HttpApiClient.Create(httpApiConfig); 24 | }); 25 | } 26 | } -------------------------------------------------------------------------------- /customerapi/Interfaces/IUserApiClient.cs: -------------------------------------------------------------------------------- 1 | namespace customerapi 2 | { 3 | using System.Collections.Generic; 4 | using WebApiClient; 5 | using WebApiClient.Attributes; 6 | 7 | public interface IUserApiClient : IHttpApiClient 8 | { 9 | [HttpGet("/users")] 10 | ITask> GetUsersAsync(); 11 | } 12 | } -------------------------------------------------------------------------------- /customerapi/Model/User.cs: -------------------------------------------------------------------------------- 1 | public class User 2 | { 3 | public int id { get; set; } 4 | 5 | public string name { get; set; } 6 | public string email { get; set; } 7 | } -------------------------------------------------------------------------------- /customerapi/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | using Steeltoe.Extensions.Configuration.ConfigServer; 11 | 12 | namespace customerapi 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | BuildWebHost(args).Run(); 19 | } 20 | 21 | public static IWebHost BuildWebHost(string[] args) => 22 | WebHost.CreateDefaultBuilder(args) 23 | .ConfigureAppConfiguration((webHostBuilderContext, configurationBuilder) => { 24 | 25 | var hostingEnvironment = webHostBuilderContext.HostingEnvironment; 26 | configurationBuilder.AddConfigServer(hostingEnvironment.EnvironmentName); 27 | }) 28 | .UseStartup() 29 | .UseUrls("http://localhost:7001/") 30 | .Build(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /customerapi/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:17797", 8 | "sslPort": 44319 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "customerapi": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/values", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /customerapi/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.HttpsPolicy; 9 | using Microsoft.AspNetCore.Mvc; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.Extensions.Logging; 13 | using Microsoft.Extensions.Options; 14 | using Microsoft.IdentityModel.Tokens; 15 | using Steeltoe.Discovery.Client; 16 | 17 | namespace customerapi 18 | { 19 | public class Startup 20 | { 21 | public Startup(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | } 25 | 26 | public IConfiguration Configuration { get; } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | public void ConfigureServices(IServiceCollection services) 30 | { 31 | services.AddSingleton(Configuration); 32 | services.Configure(options => Configuration.Bind(options)); 33 | services.AddHttpApiClient(config => 34 | { 35 | config.HttpHost = new System.Uri(Configuration.GetValue("user_service_url")); 36 | }); 37 | var audienceConfig = Configuration.GetSection("Audience"); 38 | 39 | var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(audienceConfig["Secret"])); 40 | var tokenValidationParameters = new TokenValidationParameters 41 | { 42 | ValidateIssuerSigningKey = true, 43 | IssuerSigningKey = signingKey, 44 | ValidateIssuer = true, 45 | ValidIssuer = audienceConfig["Iss"], 46 | ValidateAudience = true, 47 | ValidAudience = audienceConfig["Aud"], 48 | ValidateLifetime = true, 49 | ClockSkew = TimeSpan.Zero, 50 | RequireExpirationTime = true, 51 | }; 52 | 53 | services.AddAuthentication(o => 54 | { 55 | o.DefaultAuthenticateScheme = "TestKey"; 56 | }); 57 | 58 | services.AddAuthentication() 59 | .AddJwtBearer("TestKey", x => 60 | { 61 | x.RequireHttpsMetadata = false; 62 | x.TokenValidationParameters = tokenValidationParameters; 63 | }); 64 | services.AddDiscoveryClient(Configuration); 65 | services.AddMvc(); 66 | } 67 | 68 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 69 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 70 | { 71 | if (env.IsDevelopment()) 72 | { 73 | app.UseDeveloperExceptionPage(); 74 | } 75 | else 76 | { 77 | app.UseHsts(); 78 | } 79 | 80 | app.UseAuthentication(); 81 | app.UseDiscoveryClient(); 82 | app.UseMvc(); 83 | } 84 | 85 | public class FetcherOptions 86 | { 87 | public string BaseDataUri { get; set; } 88 | 89 | public TimeSpan FetchInterval { get; set; } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /customerapi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "spring": { 3 | "cloud": { 4 | "config": { 5 | "uri": "http://localhost:8980" 6 | } 7 | } 8 | }, 9 | "Logging": { 10 | "LogLevel": { 11 | "Default": "Debug", 12 | "System": "Information", 13 | "Microsoft": "Information" 14 | } 15 | }, 16 | "Audience": { 17 | "Secret": "Y2F0Y2hlciUyMHdvbmclMjBsb3ZlJTIwLm5ldA==", 18 | "Iss": "localhost", 19 | "Aud": "Abdulkerim Karaman" 20 | }, 21 | "eureka": { 22 | "client": { 23 | "serviceUrl": "http://localhost:8761/eureka/", 24 | "shouldFetchRegistry": true, 25 | "validateCertificates": false 26 | }, 27 | "instance": { 28 | "port": 7002, 29 | "instanceId": "http://customer-service:7002", 30 | "hostName": "customer-service", 31 | "healthCheckUrlPath": "/api/customer", 32 | "statusPageUrlPath": "/api/customer" 33 | } 34 | }, 35 | "AllowedHosts": "*", 36 | "user_service_url": "https://jsonplaceholder.typicode.com" 37 | } 38 | -------------------------------------------------------------------------------- /customerapi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Audience": { 3 | "Secret": "Y2F0Y2hlciUyMHdvbmclMjBsb3ZlJTIwLm5ldA==", 4 | "Iss": "localhost", 5 | "Aud": "Abdulkerim Karaman" 6 | }, 7 | "spring": { 8 | "application": { 9 | "name": "customer-service" 10 | } 11 | }, 12 | "eureka": { 13 | "client": { 14 | "serviceUrl": "http://localhost:8761/eureka/", 15 | "shouldFetchRegistry": true, 16 | "validateCertificates": false 17 | }, 18 | "instance": { 19 | "port": 7001, 20 | "instanceId": "http://customer-service:7001", 21 | "hostName": "customer-service", 22 | "healthCheckUrlPath": "/api/customer", 23 | "statusPageUrlPath": "/api/customer" 24 | } 25 | }, 26 | "AllowedHosts": "*" 27 | } 28 | -------------------------------------------------------------------------------- /customerapi/bin/Debug/netcoreapp2.1/customerapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/customerapi/bin/Debug/netcoreapp2.1/customerapi.dll -------------------------------------------------------------------------------- /customerapi/bin/Debug/netcoreapp2.1/customerapi.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/customerapi/bin/Debug/netcoreapp2.1/customerapi.pdb -------------------------------------------------------------------------------- /customerapi/bin/Debug/netcoreapp2.1/customerapi.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "/Users/akaraman/.dotnet/store/|arch|/|tfm|", 5 | "/Users/akaraman/.nuget/packages", 6 | "/usr/local/share/dotnet/sdk/NuGetFallbackFolder" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /customerapi/bin/Debug/netcoreapp2.1/customerapi.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "netcoreapp2.1", 4 | "framework": { 5 | "name": "Microsoft.AspNetCore.App", 6 | "version": "2.1.1" 7 | }, 8 | "configProperties": { 9 | "System.GC.Server": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /customerapi/customerapi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("customerapi")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("customerapi")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("customerapi")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | bca94e4fe7f349d9e59176d6c5872b4097b79216 2 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.RazorAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | 602c0895913b90f583f760492a18ee7534d585ab 2 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.RazorAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("customerapi.Views")] 15 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")] 16 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")] 17 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")] 18 | 19 | // Generated by the MSBuild WriteCodeFragment class. 20 | 21 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.RazorTargetAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | baf826a831a362305d370495593c844c17b423ab 2 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/customerapi/obj/Debug/netcoreapp2.1/customerapi.assets.cache -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | d139baa577fca86799ef26a74fc8335f64d308f7 2 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | /Users/akaraman/MyProjects/netmicroservice/customerapi/bin/Debug/netcoreapp2.1/customerapi.deps.json 2 | /Users/akaraman/MyProjects/netmicroservice/customerapi/bin/Debug/netcoreapp2.1/customerapi.runtimeconfig.json 3 | /Users/akaraman/MyProjects/netmicroservice/customerapi/bin/Debug/netcoreapp2.1/customerapi.runtimeconfig.dev.json 4 | /Users/akaraman/MyProjects/netmicroservice/customerapi/bin/Debug/netcoreapp2.1/customerapi.dll 5 | /Users/akaraman/MyProjects/netmicroservice/customerapi/bin/Debug/netcoreapp2.1/customerapi.pdb 6 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.csprojAssemblyReference.cache 7 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.csproj.CoreCompileInputs.cache 8 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.RazorAssemblyInfo.cache 9 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.RazorAssemblyInfo.cs 10 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.AssemblyInfoInputs.cache 11 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.AssemblyInfo.cs 12 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.RazorTargetAssemblyInfo.cache 13 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.dll 14 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/Debug/netcoreapp2.1/customerapi.pdb 15 | -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/customerapi/obj/Debug/netcoreapp2.1/customerapi.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/customerapi/obj/Debug/netcoreapp2.1/customerapi.dll -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/customerapi.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/customerapi/obj/Debug/netcoreapp2.1/customerapi.pdb -------------------------------------------------------------------------------- /customerapi/obj/Debug/netcoreapp2.1/project.razor.json: -------------------------------------------------------------------------------- 1 | { 2 | "FilePath": "/Users/akaraman/MyProjects/netmicroservice/customerapi/customerapi.csproj", 3 | "Configuration": { 4 | "ConfigurationName": "MVC-2.1", 5 | "LanguageVersion": "2.1", 6 | "Extensions": [ 7 | { 8 | "ExtensionName": "MVC-2.1" 9 | } 10 | ] 11 | }, 12 | "ProjectWorkspaceState": null, 13 | "RootNamespace": "customerapi", 14 | "Documents": [], 15 | "SerializationFormat": "0.1" 16 | } -------------------------------------------------------------------------------- /customerapi/obj/customerapi.csproj.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dgSpecHash": "2+p7PmIy4U+965xFCeicy6IYMYnzxDEeQoNA5xIyTvWaGbABlbtN+y454LpPk1dVFAAM9X8eBHcDBQBhCTvtuQ==", 4 | "success": true 5 | } -------------------------------------------------------------------------------- /customerapi/obj/customerapi.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | /Users/akaraman/MyProjects/netmicroservice/customerapi/obj/project.assets.json 7 | /Users/akaraman/.nuget/packages/ 8 | /Users/akaraman/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder 9 | PackageReference 10 | 4.8.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /customerapi/obj/customerapi.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | eurekaservice: 5 | image: eurekaservice 6 | hostname: "eurekaservice" 7 | ports: 8 | - "8761:8761" 9 | apigateway: 10 | image: apigateway 11 | links: 12 | - customer-service 13 | - eurekaservice 14 | ports: 15 | - "7000:7000" 16 | customer-service: 17 | image: customerapi 18 | links: 19 | - eurekaservice 20 | ports: 21 | - "7001:7001" 22 | product-service: 23 | image: productapi 24 | links: 25 | - eurekaservice 26 | ports: 27 | - "7002:7002" -------------------------------------------------------------------------------- /productapi/.dockerignore: -------------------------------------------------------------------------------- 1 | bin\ 2 | obj\ -------------------------------------------------------------------------------- /productapi/Controllers/ProductController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | namespace productapi.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | [ApiController] 12 | public class ProductController : ControllerBase 13 | { 14 | // GET api/product 15 | [HttpGet] 16 | [Authorize] 17 | public ActionResult> Get() 18 | { 19 | return new string[] { "Product 1", "Product 2" }; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /productapi/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/dotnet:sdk AS build-env 2 | WORKDIR /app 3 | 4 | # Copy csproj and restore as distinct layers 5 | COPY *.csproj ./ 6 | RUN dotnet restore 7 | 8 | # Copy everything else and build 9 | COPY . ./ 10 | RUN dotnet publish -c Release -o out 11 | 12 | # Build runtime image 13 | FROM microsoft/dotnet:aspnetcore-runtime 14 | WORKDIR /app 15 | COPY --from=build-env /app/out . 16 | ENV ASPNETCORE_URLS http://*:7002 17 | ENV ASPNETCORE_ENVIRONMENT docker 18 | EXPOSE 7002 19 | ENTRYPOINT ["dotnet", "productapi.dll"] -------------------------------------------------------------------------------- /productapi/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace productapi 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /productapi/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:24833", 8 | "sslPort": 44341 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "productapi": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/values", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /productapi/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.HttpsPolicy; 9 | using Microsoft.AspNetCore.Mvc; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.Extensions.Logging; 13 | using Microsoft.Extensions.Options; 14 | using Microsoft.IdentityModel.Tokens; 15 | using Steeltoe.Discovery.Client; 16 | 17 | namespace productapi 18 | { 19 | public class Startup 20 | { 21 | public Startup(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | } 25 | 26 | public IConfiguration Configuration { get; } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | public void ConfigureServices(IServiceCollection services) 30 | { 31 | var audienceConfig = Configuration.GetSection("Audience"); 32 | 33 | var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(audienceConfig["Secret"])); 34 | var tokenValidationParameters = new TokenValidationParameters 35 | { 36 | ValidateIssuerSigningKey = true, 37 | IssuerSigningKey = signingKey, 38 | ValidateIssuer = true, 39 | ValidIssuer = audienceConfig["Iss"], 40 | ValidateAudience = true, 41 | ValidAudience = audienceConfig["Aud"], 42 | ValidateLifetime = true, 43 | ClockSkew = TimeSpan.Zero, 44 | RequireExpirationTime = true, 45 | }; 46 | 47 | services.AddAuthentication(o => 48 | { 49 | o.DefaultAuthenticateScheme = "TestKey"; 50 | }) 51 | .AddJwtBearer("TestKey", x => 52 | { 53 | x.RequireHttpsMetadata = false; 54 | x.TokenValidationParameters = tokenValidationParameters; 55 | }); 56 | 57 | services.AddDiscoveryClient(Configuration); 58 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 59 | } 60 | 61 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 62 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 63 | { 64 | if (env.IsDevelopment()) 65 | { 66 | app.UseDeveloperExceptionPage(); 67 | } 68 | else 69 | { 70 | app.UseHsts(); 71 | } 72 | 73 | app.UseAuthentication(); 74 | app.UseDiscoveryClient(); 75 | app.UseMvc(); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /productapi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /productapi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Audience": { 3 | "Secret": "Y2F0Y2hlciUyMHdvbmclMjBsb3ZlJTIwLm5ldA==", 4 | "Iss": "localhost", 5 | "Aud": "Abdulkerim Karaman" 6 | }, 7 | "AllowedHosts": "*", 8 | "spring": { 9 | "application": { 10 | "name": "product-service" 11 | } 12 | }, 13 | "eureka": { 14 | "client": { 15 | "serviceUrl": "http://localhost:8761/eureka/", 16 | "shouldFetchRegistry": true, 17 | "validateCertificates": false 18 | }, 19 | "instance": { 20 | "port": 7002, 21 | "instanceId": "http://product-service:7002", 22 | "hostName": "product-service", 23 | "healthCheckUrlPath": "/api/product", 24 | "statusPageUrlPath": "/api/product" 25 | } 26 | }, 27 | "Logging": { 28 | "LogLevel": { 29 | "Default": "Warning" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /productapi/bin/Debug/netcoreapp2.1/productapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/bin/Debug/netcoreapp2.1/productapi.dll -------------------------------------------------------------------------------- /productapi/bin/Debug/netcoreapp2.1/productapi.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/bin/Debug/netcoreapp2.1/productapi.pdb -------------------------------------------------------------------------------- /productapi/bin/Debug/netcoreapp2.1/productapi.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "/Users/akaraman/.dotnet/store/|arch|/|tfm|", 5 | "/Users/akaraman/.nuget/packages", 6 | "/usr/local/share/dotnet/sdk/NuGetFallbackFolder" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /productapi/bin/Debug/netcoreapp2.1/productapi.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "netcoreapp2.1", 4 | "framework": { 5 | "name": "Microsoft.AspNetCore.App", 6 | "version": "2.1.1" 7 | }, 8 | "configProperties": { 9 | "System.GC.Server": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("productapi")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("productapi")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("productapi")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 75d121a1fbab9fcb7507718357bae010153db3fe 2 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.RazorAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | e8ad140c6c3252742eeee3b3a395a458fa7f1a71 2 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.RazorAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("productapi.Views")] 15 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")] 16 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")] 17 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")] 18 | 19 | // Generated by the MSBuild WriteCodeFragment class. 20 | 21 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.RazorTargetAssemblyInfo.cache: -------------------------------------------------------------------------------- 1 | cc4fc43992b343a381d980fe81dfbc855f98f761 2 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/obj/Debug/netcoreapp2.1/productapi.assets.cache -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 1a81ad6eb845ad128ad155e2a9e96f17f2a2b9d1 2 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | /Users/akaraman/MyProjects/netmicroservice/productapi/bin/Debug/netcoreapp2.1/productapi.deps.json 2 | /Users/akaraman/MyProjects/netmicroservice/productapi/bin/Debug/netcoreapp2.1/productapi.runtimeconfig.json 3 | /Users/akaraman/MyProjects/netmicroservice/productapi/bin/Debug/netcoreapp2.1/productapi.runtimeconfig.dev.json 4 | /Users/akaraman/MyProjects/netmicroservice/productapi/bin/Debug/netcoreapp2.1/productapi.dll 5 | /Users/akaraman/MyProjects/netmicroservice/productapi/bin/Debug/netcoreapp2.1/productapi.pdb 6 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.csprojAssemblyReference.cache 7 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.csproj.CoreCompileInputs.cache 8 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.RazorAssemblyInfo.cache 9 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.RazorAssemblyInfo.cs 10 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.AssemblyInfoInputs.cache 11 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.AssemblyInfo.cs 12 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.RazorTargetAssemblyInfo.cache 13 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.dll 14 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/Debug/netcoreapp2.1/productapi.pdb 15 | -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/obj/Debug/netcoreapp2.1/productapi.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/obj/Debug/netcoreapp2.1/productapi.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/obj/Debug/netcoreapp2.1/productapi.dll -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/productapi.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akaramanapp/microservice-ocelot/e3b485de61457d98375d22c069158dc51d738c7f/productapi/obj/Debug/netcoreapp2.1/productapi.pdb -------------------------------------------------------------------------------- /productapi/obj/Debug/netcoreapp2.1/project.razor.json: -------------------------------------------------------------------------------- 1 | { 2 | "FilePath": "/Users/akaraman/MyProjects/netmicroservice/productapi/productapi.csproj", 3 | "Configuration": { 4 | "ConfigurationName": "MVC-2.1", 5 | "LanguageVersion": "2.1", 6 | "Extensions": [ 7 | { 8 | "ExtensionName": "MVC-2.1" 9 | } 10 | ] 11 | }, 12 | "ProjectWorkspaceState": null, 13 | "RootNamespace": "productapi", 14 | "Documents": [], 15 | "SerializationFormat": "0.1" 16 | } -------------------------------------------------------------------------------- /productapi/obj/productapi.csproj.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dgSpecHash": "EJ7SrvGo7vOfXiyhgiN49oBe5yxk/kuc7CY7beTXQ8ZjOOJpyIXi02npu/wGiIvzbje75n4UkJngRr7RObMpzQ==", 4 | "success": true 5 | } -------------------------------------------------------------------------------- /productapi/obj/productapi.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | /Users/akaraman/MyProjects/netmicroservice/productapi/obj/project.assets.json 7 | /Users/akaraman/.nuget/packages/ 8 | /Users/akaraman/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder 9 | PackageReference 10 | 4.8.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /productapi/obj/productapi.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /productapi/productapi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /userapi/Controllers/UserController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace userapi.Controllers 4 | { 5 | [Route("api/[controller]")] 6 | [ApiController] 7 | public class UserController : ControllerBase 8 | { 9 | private IEventBus _eventBus; 10 | public UserController(IEventBus evantBus){ 11 | _eventBus = evantBus; 12 | } 13 | // POST api/user 14 | [HttpPost] 15 | public void Post([FromBody] string email) 16 | { 17 | // TODO: Bu kısımda user kayıt işlemleri yapılacak 18 | 19 | //User kayıt işleminden sonra MQTT event tetikleniyor. 20 | _eventBus.SendEmailEvent(email); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /userapi/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace userapi 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /userapi/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:43654", 8 | "sslPort": 44336 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "userapi": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/values", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /userapi/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.Extensions.Options; 13 | 14 | namespace userapi 15 | { 16 | public class Startup 17 | { 18 | public Startup(IConfiguration configuration) 19 | { 20 | Configuration = configuration; 21 | } 22 | 23 | public IConfiguration Configuration { get; } 24 | 25 | // This method gets called by the runtime. Use this method to add services to the container. 26 | public void ConfigureServices(IServiceCollection services) 27 | { 28 | services.AddSingleton(); 29 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 30 | } 31 | 32 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 33 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 34 | { 35 | if (env.IsDevelopment()) 36 | { 37 | app.UseDeveloperExceptionPage(); 38 | } 39 | else 40 | { 41 | app.UseHsts(); 42 | } 43 | 44 | //app.UseHttpsRedirection(); 45 | app.UseMvc(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /userapi/Util/EventBus.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using RabbitMQ.Client; 3 | 4 | public class EventBus: IEventBus { 5 | 6 | public void SendEmailEvent(string email){ 7 | var factory = new ConnectionFactory() { HostName = "192.168.1.38" }; // IP global config'den alınacak 8 | using (var connection = factory.CreateConnection()) 9 | using (var channel = connection.CreateModel()) 10 | { 11 | channel.QueueDeclare(queue: "NewUserEvent", 12 | durable: false, 13 | exclusive: false, 14 | autoDelete: false, 15 | arguments: null); 16 | 17 | string userMail = email; 18 | var body = Encoding.UTF8.GetBytes(userMail); 19 | 20 | channel.BasicPublish(exchange: "", 21 | routingKey: "NewUserEvent", 22 | basicProperties: null, 23 | body: body); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /userapi/Util/IEventBus.cs: -------------------------------------------------------------------------------- 1 | public interface IEventBus{ 2 | void SendEmailEvent(string email); 3 | } -------------------------------------------------------------------------------- /userapi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /userapi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /userapi/userapi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------