Skip to content

Instantly share code, notes, and snippets.

View sedkis's full-sized avatar
🌴
Working Remotely

Sedky Haider sedkis

🌴
Working Remotely
View GitHub Profile
// TerminateRequest checks for a specific query parameter and terminates the request if present.
func TerminateRequest(rw http.ResponseWriter, r *http.Request) {
// Check for the query parameter
if value := r.URL.Query().Get("terminate"); value == "true" {
// Prepare the data to send in response
responseData := map[string]string{
"message": "Request terminated by custom Tyk plugin.",
}
jsonData, err := json.Marshal(responseData)
if err != nil {
var auth0OAuthClientCredMiddleware = new TykJS.TykMiddleware.NewMiddleware({});
// "Cache"
zendeskAccessToken = {
token: "",
expiry: 0,
}
salesforceAccessToken = {
token: "",
@sedkis
sedkis / index.html
Created September 8, 2022 01:03 — forked from lillylangtree/index.html
sample index.html file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Spoon-Knife</title>
<LINK href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
@sedkis
sedkis / README.md
Created August 16, 2022 11:19
Go Plugin
  1. compile plugin

  2. load into gateway

  3. use the below YAML:

apiVersion: tyk.tyk.io/v1alpha1
from locust import HttpLocust, TaskSet, task
def index(l):
l.client.get("/")
def stats(l):
l.client.get("/stats/requests")
class UserTasks(TaskSet):
# one can specify tasks like this
@sedkis
sedkis / gist:df682fda62c9bd4a1e91326bfe2ed7cf
Last active August 24, 2023 15:33
Install docker on AL2
sudo yum -y install docker git; \
 sudo service docker start; \
 sudo usermod -a -G docker ec2-user; \
 sudo chkconfig docker on; \
 sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose; \
 sudo chmod +x /usr/local/bin/docker-compose; \
 sudo reboot;

Here is a quick and dirty cmd that I threw together.

@sedkis
sedkis / install-docker.md
Created May 27, 2022 18:27 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
{
"swagger":"2.0",
"info":{
"description":"Social Media API",
"version":"1.0.0",
"title":"Social Media API"
},
"host":"34.148.19.142:8080",
"tags":[
{
@sedkis
sedkis / swagger
Last active April 7, 2022 21:16
Edge Gateway Swagger
swagger: '2.0'
info:
title: httpbin.org
description: API Management facade for a very handy and free online HTTP tool.
version: '1.0'
host: adverse-leash-gw.aws-use1.cloud-ara.tyk.io/httpbin
schemes:
- http
- https
paths:
@sedkis
sedkis / tyk-bootstrap.sh
Last active October 5, 2022 19:38
Tyk Portal Bootstrap
TOKEN=1bfa65c26a66487157941e23c0ed5a6e # User API Key / Token
ORG=622ba349eaf9c2000181a507 # Dashboard Org ID
CNAME=tyk-portal.localhost:3000 # Portal CNAME you wish to set
DASH_URL=http://localhost:3000 # This can be an IP, a hostname, etc, but Port is necessary if non-standard
# Create Portal.
curl -X POST $DASH_URL/api/portal/configuration \
--header "Authorization: $TOKEN" \
--data "{}"