Main project #1

Merged
raul merged 33 commits from testing into main 2024-06-14 07:49:34 +02:00
2 changed files with 18 additions and 2 deletions
Showing only changes of commit 8e04491386 - Show all commits

View File

@ -22,6 +22,7 @@ to quickly create a Cobra application.`,
if err := setServerParameters(cmd); err != nil {
log.Fatalf("Error happened trying to set parameters: %v\n", err)
}
server()
},
}

View File

@ -2,6 +2,7 @@ package cmd
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
@ -11,6 +12,20 @@ var (
)
func server() {
router := gin.Default
getJSON()
router := gin.Default()
router.GET("/api/valencia", returnWeather)
fmt.Printf("Listening on port %v...\n", listenPort)
router.Run("localhost:" + listenPort)
}
func returnWeather(c *gin.Context) {
jsonData := getJSON()
c.IndentedJSON(http.StatusOK, jsonData)
//textBytes := []byte(jsonData)
// aemetRequest := root{}
// err := json.Unmarshal(textBytes, &aemetRequest)
// if err != nil {
// log.Fatalf("Error occurred unmarshalling data: %v\n", err)
// }
}