Created
May 3, 2018 12:04
-
-
Save adigunhammedolalekan/aa058266ca5dc3f4658569cdfc77f3fd to your computer and use it in GitHub Desktop.
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 ( | |
"github.com/gorilla/mux" | |
"go-contacts/app" | |
"os" | |
"fmt" | |
"net/http" | |
) | |
func main() { | |
router := mux.NewRouter() | |
router.Use(app.JwtAuthentication) //attach JWT auth middleware | |
port := os.Getenv("PORT") //Get port from .env file, we did not specify any port so this should return an empty string when tested locally | |
if port == "" { | |
port = "8000" //localhost | |
} | |
fmt.Println(port) | |
err := http.ListenAndServe(":" + port, router) //Launch the app, visit localhost:8000/api | |
if err != nil { | |
fmt.Print(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment