You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
666 B

  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "git.aiterp.net/lucifer/new-server/models"
  6. )
  7. func (client *Client) GetHandlers(ctx context.Context, fetchStr string) ([]models.EventHandler, error) {
  8. handlers := make([]models.EventHandler, 0, 16)
  9. err := client.Fetch(ctx, "GET", "/api/event-handlers", &handlers, nil)
  10. if err != nil {
  11. return nil, err
  12. }
  13. return handlers, nil
  14. }
  15. func (client *Client) DeleteHandler(ctx context.Context, id int) (*models.EventHandler, error) {
  16. var handler models.EventHandler
  17. err := client.Fetch(ctx, "DELETE", fmt.Sprintf("/api/event-handlers/%d", id), &handler, nil)
  18. if err != nil {
  19. return nil, err
  20. }
  21. return &handler, nil
  22. }