|
@@ -104,7 +104,7 @@ func generateHandler(r *mux.Router, model interface{}) {
|
|
// Generate API patterns prefixing "api" path
|
|
// Generate API patterns prefixing "api" path
|
|
|
|
|
|
for _, p := range patterns {
|
|
for _, p := range patterns {
|
|
- apiPatterns = append(apiPatterns, PathPattern{path.Join("/", "api", p.PathPattern), "", []string{"GET"}})
|
|
|
|
|
|
+ apiPatterns = append(apiPatterns, PathPattern{path.Join("/", "api", p.PathPattern), "", p.Methods})
|
|
}
|
|
}
|
|
|
|
|
|
// Install standard paths
|
|
// Install standard paths
|
|
@@ -128,7 +128,7 @@ func generateHandler(r *mux.Router, model interface{}) {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
- if model == "jobs" {
|
|
|
|
|
|
+ if modelName(model) == "Job" {
|
|
for _, pattern := range filePatterns {
|
|
for _, pattern := range filePatterns {
|
|
log.Printf("Register handler %s", pattern.Path(pluralizedModelName(model)))
|
|
log.Printf("Register handler %s", pattern.Path(pluralizedModelName(model)))
|
|
r.Handle(pattern.Path(pluralizedModelName(model)), jwtCookie.Handler(recoverHandler(modelHandler(pluralizedModelName(model), pattern)))).Methods(pattern.Methods...)
|
|
r.Handle(pattern.Path(pluralizedModelName(model)), jwtCookie.Handler(recoverHandler(modelHandler(pluralizedModelName(model), pattern)))).Methods(pattern.Methods...)
|
|
@@ -293,6 +293,10 @@ func respondWithError(w http.ResponseWriter, r *http.Request, err error) {
|
|
|
|
|
|
func modelHandler(model string, pattern PathPattern) http.Handler {
|
|
func modelHandler(model string, pattern PathPattern) http.Handler {
|
|
fn := func(w http.ResponseWriter, r *http.Request) {
|
|
fn := func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
+
|
|
|
|
+ // Replace "api" prefix
|
|
|
|
+ pattern.PathPattern = strings.Replace(pattern.PathPattern, "/api", "", -1)
|
|
|
|
+
|
|
switch r.Method {
|
|
switch r.Method {
|
|
case "GET":
|
|
case "GET":
|
|
get(w, r, model, pattern)
|
|
get(w, r, model, pattern)
|