This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM openjdk:8-jdk | |
RUN mkdir -p /usr/app | |
WORKDIR /usr/app | |
COPY ./target/my-jar.jar . | |
EXPOSE 8181 | |
CMD /usr/bin/java -jar \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
my-java-service: | |
image: 'my-java-service:latest' | |
secrets: | |
- source: my-secret-DEV | |
target: my-secret | |
environment: | |
- SPRING_PROFILES_ACTIVE=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
my-java-service: | |
image: 'my-java-service:latest' | |
secrets: | |
- source: my-secret-prd | |
target: my-secret | |
environment: | |
- SPRING_PROFILES_ACTIVE=prd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableWebSecurity | |
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |
private String apiUser; | |
private String apiPassword; | |
@Autowired | |
public WebSecurityConfig( | |
@Value("${web.security.api.user}") String apiUser, // stored in plain text in application.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Makes API call to worldtimezone/api/timezone, and gets the time of the | |
// first 3 timezones and pretty formats it | |
function myVirtualHandler (request, session, config) { | |
//Make api call to upstream target | |
newRequest = { | |
"Method": "GET", | |
"Domain": "http://worldtimeapi.org", | |
"resource": "/api/timezone" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myVirtualHandler(request, session, config) { | |
//Make api call to upstream target | |
newRequest = { | |
"Headers": {"Authorization":"103cbe6f3c9443575cc52451cd051ecb"}, | |
"Method": "POST", | |
"Body":keyrequest, | |
"Domain": "http://www.tyk-test.com:3000", | |
"resource": "/api/keys", | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var preTransformContentType = new TykJS.TykMiddleware.NewMiddleware({}); | |
preTransformContentType.NewProcessRequest(function(request, session, config) { | |
log("Running sample PRE PROCESSOR preTransformContentType middleware"); | |
var thisSession = JSON.parse(TykGetKeyData(request.Headers["Authorization"], config.APIID)) | |
if (thisSession.status == "error" || thisSession.expires >= 1 && thisSession.expires < Math.round((new Date()).getTime() / 1000)) { | |
log("Key expired, redirecting to login") | |
request.ReturnOverrides.ResponseCode = 301 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you have a 50% chance of winning combined with a 40% chance of winning | |
// It is the same as having a 90% chance of winning combined with a 0 percent chance of winning | |
percentOfWin = 0.5; | |
percentOfWinTwo = 0.4; | |
totalWins = 0; | |
n = 100000; | |
while (n > 0) { | |
// First Draw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Tyk Cache API", | |
"api_id": "2", | |
"org_id": "default", | |
"auth": {}, | |
"use_keyless": true, | |
"version_data": { | |
"not_versioned": true, | |
"versions": { | |
"Default": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"listen_port": 8080, | |
"secret": "352d20ee67be67f6340b4c0605b044b7", | |
"template_path": "/opt/tyk-gateway/templates", | |
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js", | |
"middleware_path": "/opt/tyk-gateway/middleware", | |
"use_db_app_configs": false, | |
"app_path": "/opt/tyk-gateway/apps/", | |
"storage": { | |
"type": "redis", |
OlderNewer