first coomit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gorilla/mux"
|
||||
"nbarest/lib/persistence"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ServeAPI(endpoint string,dbhandler persistence.DatabaseHandler) error{
|
||||
handler:=NewPlayerServiceHandler(dbhandler)
|
||||
r:=mux.NewRouter()
|
||||
playersrouter:=r.PathPrefix("/players").Subrouter()
|
||||
|
||||
playersrouter.Path("/{SearchCriteria}/{search}").HandlerFunc(handler.FindPlayerHandler).Methods("GET")
|
||||
playersrouter.Path("/").HandlerFunc(handler.FindAllPlayerHandler).Methods("GET")
|
||||
playersrouter.Path("/").HandlerFunc(handler.NewPlayerHandler).Methods("POST")
|
||||
fmt.Println("listen")
|
||||
return http.ListenAndServe(endpoint,r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user