Last active
August 31, 2020 16:06
-
-
Save digitallysavvy/a686dde947173fe9e072d3778a7ff4f7 to your computer and use it in GitHub Desktop.
example of main.go that retrieves the Agora credentials from the local environment variables.
This file contains hidden or 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 ( | |
"log" | |
"os" | |
"github.com/gin-gonic/gin" | |
) | |
var appID, appCertificate string | |
func main() { | |
appIDEnv, appIDExists := os.LookupEnv("APP_ID") | |
appCertEnv, appCertExists := os.LookupEnv("APP_CERTIFICATE") | |
if !appIDExists || !appCertExists { | |
log.Fatal("FATAL ERROR: ENV not properly configured, check APP_ID and APP_CERTIFICATE") | |
} else { | |
appID = appIDEnv | |
appCertificate = appCertEnv | |
} | |
api := gin.Default() | |
api.GET("/ping", func(c *gin.Context) { | |
c.JSON(200, gin.H{ | |
"message": "pong", | |
}) | |
}) | |
api.Run(":8080") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment