fix: replace index redirection

This commit is contained in:
trafficlunar 2025-03-20 22:49:08 +00:00
parent 4fb7905f9d
commit 4f8ee6cf9c
2 changed files with 7 additions and 2 deletions

View file

@ -2,7 +2,7 @@
![written in go](https://github.com/intergrav/devins-badges/blob/v3/assets/cozy/built-with/go_64h.png?raw=true) ![written in go](https://github.com/intergrav/devins-badges/blob/v3/assets/cozy/built-with/go_64h.png?raw=true)
trafficlunar's API trafficlunar's api
## features ## features

View file

@ -1,6 +1,7 @@
package server package server
import ( import (
"encoding/json"
"log/slog" "log/slog"
"net/http" "net/http"
"os" "os"
@ -43,7 +44,11 @@ func NewRouter() {
})) }))
r.Get("/", func(w http.ResponseWriter, r *http.Request) { r.Get("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "https://trafficlunar.net", http.StatusPermanentRedirect) w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{
"name": "trafficlunar's api",
"url": "https://github.com/trafficlunar/api",
})
}) })
r.Get("/hit", handler.HandleGetHitCounter) r.Get("/hit", handler.HandleGetHitCounter)