mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 07:08:59 +00:00
Return 404 when no store is configured (not 200)
This commit is contained in:
@@ -3,6 +3,7 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/rancher/norman/httperror"
|
||||
"github.com/rancher/norman/types"
|
||||
)
|
||||
|
||||
@@ -15,11 +16,13 @@ func CreateHandler(apiContext *types.APIContext, next types.RequestHandler) erro
|
||||
}
|
||||
|
||||
store := apiContext.Schema.Store
|
||||
if store != nil {
|
||||
data, err = store.Create(apiContext, apiContext.Schema, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if store == nil {
|
||||
return httperror.NewAPIError(httperror.NotFound, "no store found")
|
||||
}
|
||||
|
||||
data, err = store.Create(apiContext, apiContext.Schema, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
apiContext.WriteResponse(http.StatusCreated, data)
|
||||
|
Reference in New Issue
Block a user