Allow CORS origins
This commit is contained in:
@ -63,10 +63,10 @@ func (c *DefaultApiController) Routes() Routes {
|
||||
c.GetJournalEntryForDate,
|
||||
},
|
||||
{
|
||||
"WriteJournalEntryForDate",
|
||||
"WriteJournalEntry",
|
||||
strings.ToUpper("Post"),
|
||||
"/api/v1/journal/entry/{date}",
|
||||
c.WriteJournalEntryForDate,
|
||||
"/api/v1/journal/entry/",
|
||||
c.WriteJournalEntry,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -103,11 +103,8 @@ func (c *DefaultApiController) GetJournalEntryForDate(w http.ResponseWriter, r *
|
||||
|
||||
}
|
||||
|
||||
// WriteJournalEntryForDate -
|
||||
func (c *DefaultApiController) WriteJournalEntryForDate(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
dateParam := params["date"]
|
||||
|
||||
// WriteJournalEntry -
|
||||
func (c *DefaultApiController) WriteJournalEntry(w http.ResponseWriter, r *http.Request) {
|
||||
journalEntryParam := JournalEntry{}
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
@ -119,7 +116,7 @@ func (c *DefaultApiController) WriteJournalEntryForDate(w http.ResponseWriter, r
|
||||
c.errorHandler(w, r, err, nil)
|
||||
return
|
||||
}
|
||||
result, err := c.service.WriteJournalEntryForDate(r.Context(), dateParam, journalEntryParam)
|
||||
result, err := c.service.WriteJournalEntry(r.Context(), journalEntryParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
|
||||
Reference in New Issue
Block a user