Skip to content
Snippets Groups Projects
handler.go 468 B
Newer Older
  • Learn to ignore specific revisions
  • Alex Ellis's avatar
    Alex Ellis committed
    package main
    
    import (
    	"fmt"
    	"io/ioutil"
    	"log"
    	"os"
    
    func handle(body []byte) {
    	key := os.Getenv("Http_X_Api_Key")
    
    	secretBytes, err := ioutil.ReadFile("/run/secrets/secret_api_key")
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	secret := strings.TrimSpace(string(secretBytes))
    
    	if key == secret {
    
    Alex Ellis's avatar
    Alex Ellis committed
    		fmt.Println("Unlocked the function!")
    	} else {
    		fmt.Println("Access denied!")
    	}
    }
    
    func main() {
    	bytes, _ := ioutil.ReadAll(os.Stdin)
    
    Alex Ellis's avatar
    Alex Ellis committed
    }