Created
February 21, 2023 10:28
-
-
Save mitchallen/8de25068f7ccbc7c330857a261d247b3 to your computer and use it in GitHub Desktop.
Go (Golang) server using the Gin framework
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
| /** | |
| * Author: Mitch Allen | |
| * File: server.go | |
| */ | |
| package main | |
| import "github.com/gin-gonic/gin" | |
| func main() { | |
| r := gin.Default() | |
| r.GET("/", func(c *gin.Context) { | |
| c.JSON(200, gin.H{ | |
| "message": "Hello, world!", | |
| }) | |
| }) | |
| // listen and serve on 0.0.0.0:8080 | |
| // on windows "localhost:8080" | |
| // can be overriden with the PORT env var | |
| r.Run() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment