<commit_before>package main

import (
	"github.com/gin-gonic/gin"
)

type TodoHandlers struct {
	Client *DbClient
}

// Add a new todo
func (h *TodoHandlers) AddTodo(c *gin.Context) {
	var todo Todo
	if !c.Bind(&todo) {
		c.JSON(400, "problem decoding body")
		return
	}

	created, err := h.Client.AddTodo(todo)
	if err != nil {
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(201, created)
}

// Get all todos as an array
func (h *TodoHandlers) GetTodos(c *gin.Context) {
	todos, err := h.Client.GetTodos()
	if err != nil {
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(200, todos)
}

// Get a specific todo by id
func (h *TodoHandlers) GetTodo(c *gin.Context) {
	id := c.Params.ByName("id")
	todo, err := h.Client.GetTodo(id)
	if err != nil {
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(200, todo)
}

// Delete a todo by id
func (h *TodoHandlers) DeleteTodo(c *gin.Context) {
	id := c.Params.ByName("id")

	if err := h.Client.DeleteTodo(id); err != nil {
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(204, nil)
}<commit_msg>fix(delete): solved no-content error by using Data instead of JSON to set response<commit_after>package main

import (
	"github.com/gin-gonic/gin"
	"log"
)

type TodoHandlers struct {
	Client *DbClient
}

// Add a new todo
func (h *TodoHandlers) AddTodo(c *gin.Context) {
	var todo Todo
	if !c.Bind(&todo) {
		c.JSON(400, "problem decoding body")
		return
	}

	created, err := h.Client.AddTodo(todo)
	if err != nil {
		log.Print(err)
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(201, created)
}

// Get all todos as an array
func (h *TodoHandlers) GetTodos(c *gin.Context) {
	todos, err := h.Client.GetTodos()
	if err != nil {
		log.Print(err)
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(200, todos)
}

// Get a specific todo by id
func (h *TodoHandlers) GetTodo(c *gin.Context) {
	id := c.Params.ByName("id")
	todo, err := h.Client.GetTodo(id)
	if err != nil {
		log.Print(err)
		c.JSON(500, "problem decoding body")
		return
	}

	c.JSON(200, todo)
}

// Delete a todo by id
func (h *TodoHandlers) DeleteTodo(c *gin.Context) {
	id := c.Params.ByName("id")

	if err := h.Client.DeleteTodo(id); err != nil {
		log.Print(err)
		c.JSON(500, "problem decoding body")
		return
	}

	c.Data(204, "application/json", make([]byte, 0))
}
{'fraction_non_alphanumeric': 0.1576923076923077, 'fraction_numerical': 0.023504273504273504, 'mean_word_length': 3.510597302504817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6831542', 'n_tokens_mistral': 1039, 'n_tokens_neox': 948, 'n_words': 249}