golanglabs

Log | Files | Refs | README | LICENSE

webserver.go (397B)


      1 package main
      2 
      3 import (
      4 	"encoding/json"
      5 	"fmt"
      6 	"io/ioutil"
      7 	"os"
      8 )
      9 
     10 func main() {
     11 
     12 }
     13 
     14 type Routes struct {
     15 	Route string `json:"path"`
     16 }
     17 
     18 func loadRoutes() {
     19 	jsonFile, err := os.Open("routes.json")
     20 
     21 	if err != nil {
     22 		fmt.Println(err)
     23 	}
     24 
     25 	fmt.Println("Loaded routes.")
     26 
     27 	defer jsonFile.Close()
     28 
     29 	byteValue, _ := ioutil.ReadAll(jsonFile)
     30 	var routes Routes
     31 	json.Unmarshal(byteValue, &routes)
     32 }