package main

import (
	"log"
	"net/http"

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

func main() {
	wf, err := NewWebfinger("dma", "hello.yetaga.in")
	if err != nil {
		log.Fatalln(err)
	}
	pp, err := NewProfileProvider("hello.yetaga.in")
	if err != nil {
		log.Fatalln(err)
	}

	r := chi.NewRouter()
	r.Get("/.well-known/webfinger", WebFingerHandler(wf))
	r.Get("/users/{user}", ProfileHandler(pp))

	log.Println("listening on http://0.0.0.0:8008")
	err = http.ListenAndServe(":8008", r)
	if err != nil {
		log.Fatalln(err)
	}
}
