> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mergent.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Chi

> Learn how to create your first task using Go and Chi

<Snippet file="quickstart/1_define_task.mdx" />

```go main.go
package main

import (
	"io"
	"log"
	"net/http"

	"github.com/go-chi/chi"
)

func main() {
	r := chi.NewRouter()

	r.Post("/api/tasks", func(w http.ResponseWriter, r *http.Request) {
		body, _ := io.ReadAll(r.Body)

		err := performTask(string(body))
		if err != nil {
			// task failed, respond with 500 so Mergent will retry
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}

		// task was successful, respond with 200
		w.WriteHeader(http.StatusOK)
	})

	http.ListenAndServe(":3000", r)
}

func performTask(body string) error {
	// This is where you'll perform your task.
	// For now, we'll just log it.
	log.Println("Performing task: ", body)

	return nil
}
```

<Snippet file="callout_params_api_reference.mdx" />

<Snippet file="quickstart/2_get_handler_url.mdx" />

<Snippet file="quickstart/3_create_first_task.mdx" />

<Snippet file="quickstart/4_next_steps.mdx" />

<AccordionGroup>
  <Snippet file="quickstart/accordion_use_cron_dashboard.mdx" />

  <Snippet file="quickstart/accordion_create_task_go.mdx" />
</AccordionGroup>

<Snippet file="learn_more.mdx" />
