This repository has been archived on 2024-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
helseveileder/backend/cmd/api/main.go
Sindre Kjelsrud dd8f22b043
added POST-endpoint for userform
Co-authored-by: haraldnilsen <harald_998@hotmail.com>
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
2023-12-21 19:31:14 +01:00

32 lines
595 B
Go

package main
import (
"fmt"
"io"
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
// Define a basic GET request handler
router.GET("/ping", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
})
// Info about user
router.POST("/submitform", func(c *gin.Context) {
jsonData, err := io.ReadAll(c.Request.Body)
if err != nil {
// Handle error
}
fmt.Print(string(jsonData))
})
// Run the server on port 8080
router.Run(":8080")
}