Skip to content

Instantly share code, notes, and snippets.

@digitallysavvy
Last active August 31, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitallysavvy/a686dde947173fe9e072d3778a7ff4f7 to your computer and use it in GitHub Desktop.
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.
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