package api import ( "net/http" "atlas9.dev/c/core" "atlas9.dev/c/demo/bots" ) func BotsApi(mux *http.ServeMux, impl *BotsImpl) { mux.HandleFunc("POST /Bots_Save", impl.Save) mux.HandleFunc("POST /Bots_Get", impl.Get) mux.HandleFunc("POST /Bots_List", impl.List) mux.HandleFunc("POST /Bots_Delete", impl.Delete) } type Bots_SaveReq struct { Bot bots.Bot } type Bots_SaveRes struct { Bot bots.Bot } type Bots_GetReq struct { ID core.ID Tenant core.ID } type Bots_GetRes struct { Bot bots.Bot } type Bots_ListReq struct { Tenant core.ID Page core.PageReq } type Bots_ListRes struct { Page core.Page[bots.Bot] } type Bots_DeleteReq struct { ID core.ID Tenant core.ID } type Bots_DeleteRes struct{} // Prepare functions func (b *Bots_SaveReq) Prepare() error { // TODO this feels more like a store-level concern? // the store should be enforcing data integrity at least. if b.Bot.ID.IsEmpty() { b.Bot.ID = core.NewID("bot") } return nil } func (b *Bots_GetReq) Prepare() error { return nil } func (b *Bots_ListReq) Prepare() error { return nil } func (b *Bots_DeleteReq) Prepare() error { return nil }