admissionServer/index.go

32 lines
760 B
Go
Raw Normal View History

2018-11-18 09:52:24 +01:00
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)
}