diff --git a/index.go b/index.go new file mode 100644 index 0000000..eb48e4d --- /dev/null +++ b/index.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "html" + "log" + "net/http" + + "github.com/gorilla/mux" +) + +func main() { + + muxRouter := mux.NewRouter().StrictSlash(true) + muxRouter.HandleFunc("/", index) + muxRouter.HandleFunc("/getfromdb", getAll) + muxRouter.HandleFunc("/getfromdb/{primaryKey}", getIndex) + log.Fatal(http.ListenAndServe(":8080", muxRouter)) +} + +func index(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) +} +func getAll(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Tutaj dostaniesz wyniki z bazy danych") +} +func getIndex(w http.ResponseWriter, r *http.Request) { + args := mux.Vars(r) + pk := args["primaryKey"] + fmt.Fprintf(w, "Tutaj bedzie wynik dla PK = %s", pk) +}