Allow CORS origins
This commit is contained in:
@ -22,7 +22,7 @@ import (
|
||||
type DefaultApiRouter interface {
|
||||
DeleteJournalEntryForDate(http.ResponseWriter, *http.Request)
|
||||
GetJournalEntryForDate(http.ResponseWriter, *http.Request)
|
||||
WriteJournalEntryForDate(http.ResponseWriter, *http.Request)
|
||||
WriteJournalEntry(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
|
||||
|
||||
@ -33,5 +33,5 @@ type DefaultApiRouter interface {
|
||||
type DefaultApiServicer interface {
|
||||
DeleteJournalEntryForDate(context.Context, string) (ImplResponse, error)
|
||||
GetJournalEntryForDate(context.Context, string) (ImplResponse, error)
|
||||
WriteJournalEntryForDate(context.Context, string, JournalEntry) (ImplResponse, error)
|
||||
WriteJournalEntry(context.Context, JournalEntry) (ImplResponse, error)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -48,13 +48,13 @@ func (s *DefaultApiService) GetJournalEntryForDate(ctx context.Context, date str
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("GetJournalEntryForDate method not implemented")
|
||||
}
|
||||
|
||||
// WriteJournalEntryForDate -
|
||||
func (s *DefaultApiService) WriteJournalEntryForDate(ctx context.Context, date string, journalEntry JournalEntry) (ImplResponse, error) {
|
||||
// TODO - update WriteJournalEntryForDate with the required logic for this service method.
|
||||
// WriteJournalEntry -
|
||||
func (s *DefaultApiService) WriteJournalEntry(ctx context.Context, journalEntry JournalEntry) (ImplResponse, error) {
|
||||
// TODO - update WriteJournalEntry with the required logic for this service method.
|
||||
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
||||
//return Response(200, nil),nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("WriteJournalEntryForDate method not implemented")
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("WriteJournalEntry method not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user