0

Change layout to more go-style-ish, replace some modules

* Deejay files, split them to achieve go-style project layout
* Replace logrus with log/slog module to reduce dependencies
* Replace gopkg.in/ini.v1 with github.com/wlevene/ini to make sure all modules BSD licensed
* Update linter config && fix tons of linter warnings
* Update .gitignore
* Update README.md
This commit is contained in:
eleksir
2025-11-09 22:16:04 +03:00
parent c5f4682cb9
commit 79d9a2f604
211 changed files with 12879 additions and 7732 deletions

37
cmd/joyproxy/main.go Normal file
View File

@@ -0,0 +1,37 @@
// Package main represents entry point function of application.
package main
import (
"net/http"
"os"
"time"
"joyproxy/internal/joyproxy"
"joyproxy/internal/log"
)
// main application entry point.
func main() {
joyproxy.LoadConf()
log.Init(joyproxy.Cfg.Loglevel, os.Stderr)
http.HandleFunc("/joyproxy/", joyproxy.JoyproxyHandler)
http.HandleFunc("/joyurl", joyproxy.JoyurlHandler)
log.Infof("Starting application on port %v\n", joyproxy.Cfg.Port)
// To prevent slow loris ddos, we have to define custom handler because builtin http.ListenAndServe() have no
// timeout and sits here forever.
server := &http.Server{
Addr: joyproxy.Cfg.Port,
ReadHeaderTimeout: time.Duration(joyproxy.Cfg.Timeout) * time.Second,
ReadTimeout: time.Duration(joyproxy.Cfg.Timeout) * time.Second,
WriteTimeout: time.Duration(joyproxy.Cfg.Timeout) * time.Second,
IdleTimeout: time.Duration(joyproxy.Cfg.Timeout) * time.Second,
}
log.Warn(server.ListenAndServe().Error())
}
/* vim: set ft=go noet ai ts=4 sw=4 sts=4: */