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
<dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>software.amazon.awssdk</groupId> | |
<artifactId>bom</artifactId> | |
<version>2.17.230</version> | |
<type>pom</type> | |
<scope>import</scope> | |
</dependency> |
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
import com.amazonaws.encryptionsdk.AwsCrypto; | |
import com.amazonaws.encryptionsdk.CommitmentPolicy; | |
import com.amazonaws.encryptionsdk.CryptoResult; | |
import com.amazonaws.encryptionsdk.kms.KmsMasterKey; | |
import com.amazonaws.encryptionsdk.kms.KmsMasterKeyProvider; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.susamn.models.OutboundPayload; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; |
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
func main() { | |
mux := http.NewServeMux() | |
ultimateHandler := http.HandlerFunc(myhandler) | |
mux.Handle("/", logHandler(authHandler(ultimateHandler))) | |
log.Println("Listening on :3000...") | |
err := http.ListenAndServe(":3000", mux) | |
log.Fatal(err) | |
} |
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
func authHandler(next http.Handler) http.Handler { | |
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
log.Println("Executing auth handler") | |
// Do auth hander stuff | |
next.ServeHTTP(w, r) | |
}) | |
} | |
func logHandler(next http.Handler) http.Handler { | |
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
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
func myhandler(w http.ResponseWriter, r *http.Request) { | |
log.Println("Executing my handler") | |
w.Write([]byte("OK")) | |
} |
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
curl -s 'https://medium.com/@susamn/stats?limit=25&bucketType=MONTH&filter=not-response' \ | |
-H 'authority: medium.com' \ | |
-H 'sec-ch-ua: "Google Chrome";v="93", " Not;A Brand";v="99", "Chromium";v="93"' \ | |
-H 'sec-ch-ua-mobile: ?0' \ | |
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36' \ | |
-H 'content-type: application/json' \ | |
-H 'accept: application/json' \ | |
-H 'x-obvious-cid: web' \ | |
-H 'sec-ch-ua-platform: "macOS"' \ | |
-H 'sec-fetch-site: same-origin' \ |
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
package main | |
import ( | |
"fmt" | |
) | |
type Data []int | |
type UnaryOperation func(op int) int | |
func (d Data) Apply(operation UnaryOperation) Data { |
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
package main | |
import ( | |
"net/http" | |
) | |
type Subscriber struct { | |
Name, Address, LocationId, SubscriptionName string | |
Tenure int8 | |
BalanceDue float32 |
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
func delegate(data string) (*Response, err){ | |
response, err := backend.call(data) | |
if err != nil{ | |
return nil, errors.New("The call to backend failed") | |
}else{ | |
validatedResponse, err := response.validate() | |
if err != nil{ | |
return nil, errors.New("The response obtained from backend has errors and could not be validated") | |
}else{ | |
return validatedResponse, nil |
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
func delegate(data string) (*Response, err){ | |
response, err := backend.call(data) | |
if err != nil{ | |
return nil, errors.New("The call to backend failed") | |
} | |
validatedResponse, err := response.validate() | |
if err != nil{ |
NewerOlder