gosimplenpm/main.go

46 lines
1.1 KiB
Go
Raw Normal View History

package main
import (
"gosimplenpm/config"
"log"
"net/http"
)
func main() {
var cfg config.Config
err := config.LoadConfiguration("userdata/config.json", &cfg)
if err != nil {
log.Fatalf("Config is not loaded: %+v\n", err)
}
app := &application{
conf: cfg,
}
log.Print("Starting server on port 4000")
err = http.ListenAndServe(":4000", app.Routes())
log.Fatal(err)
}
// func main() {
// router := mux.NewRouter()
// router.NewRoute().Path("/{name}").Methods("PUT")
// router.NewRoute().Path("/{name}").Methods("GET")
// rMatch := &mux.RouteMatch{}
// u := url.URL{Path: "/@ookusanya%2fsimplepackone"}
// req := http.Request{Method: "GET", URL: &u}
// x := router.Match(&req, rMatch)
// fmt.Println("Is Matched: ", x)
// reqt := http.Request{Method: "PUT", URL: &u}
// g := router.Match(&reqt, rMatch)
// fmt.Println("Is Matched: ", g)
// ut := url.URL{Path: "/@ookusanya%2fsimplepackone/-/simplepackone-1.0.0.tgz"}
// rt := http.Request{Method: "PUT", URL: &ut}
// gt := router.Match(&rt, rMatch)
// fmt.Println("Is Matched: ", gt)
// }