fix api & configapi

pull/94/head
Aloïs Micard 4 years ago
parent 5429bb70d8
commit 205235aa7b
No known key found for this signature in database
GPG Key ID: 1A0EB82F071F5EFE

@ -136,8 +136,6 @@ func (state *State) searchResources(w http.ResponseWriter, r *http.Request) {
})
}
w.WriteHeader(http.StatusOK)
// Write pagination headers
writePagination(w, searchParams, totalCount)
@ -207,7 +205,6 @@ func (state *State) addResource(w http.ResponseWriter, r *http.Request) {
log.Info().Str("url", res.URL).Msg("Successfully saved resource")
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(res); err != nil {
log.Err(err).Msg("error while encoding response")
w.WriteHeader(http.StatusInternalServerError)
@ -229,8 +226,6 @@ func (state *State) scheduleURL(w http.ResponseWriter, r *http.Request) {
}
log.Info().Str("url", url).Msg("successfully scheduled URL")
w.WriteHeader(http.StatusOK)
}
func getSearchParams(r *http.Request) (*api.ResSearchParams, error) {

@ -329,6 +329,9 @@ func TestSearchResources(t *testing.T) {
s := State{db: dbMock}
s.searchResources(rec, req)
if rec.Code != http.StatusOK {
t.Fail()
}
if rec.Header().Get(api.PaginationCountHeader) != "150" {
t.Fail()
}

@ -27,7 +27,7 @@ func (state *State) Name() string {
// CommonFlags return process common flags
func (state *State) CommonFlags() []string {
return []string{}
return []string{process.HubURIFlag}
}
// CustomFlags return process custom flags
@ -53,6 +53,12 @@ func (state *State) Initialize(provider process.Provider) error {
}
state.db = db
pub, err := provider.Publisher()
if err != nil {
return err
}
state.pub = pub
defaultValues := map[string]string{}
for _, value := range provider.GetValues("default-value") {
parts := strings.Split(value, "=")

Loading…
Cancel
Save