mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-04-19 08:36:50 +00:00
Replace Gorilla Mux with net/http router
This commit is contained in:
parent
f6d8bce2d5
commit
3742acf149
7
go.mod
7
go.mod
@ -1,8 +1,5 @@
|
||||
module idicon
|
||||
|
||||
go 1.20
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.4.0
|
||||
github.com/gorilla/mux v1.8.1
|
||||
)
|
||||
require github.com/BurntSushi/toml v1.4.0
|
||||
|
2
go.sum
2
go.sum
@ -1,4 +1,2 @@
|
||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/gorilla/mux"
|
||||
"idicon/icons"
|
||||
"image/gif"
|
||||
"image/jpeg"
|
||||
@ -26,7 +25,7 @@ func pageRequestHandler(w http.ResponseWriter, _ *http.Request) {
|
||||
}
|
||||
|
||||
func requestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
id := mux.Vars(r)["id"]
|
||||
id := r.PathValue("id")
|
||||
|
||||
size, err := strconv.Atoi(r.URL.Query().Get("s"))
|
||||
if err != nil {
|
||||
@ -135,9 +134,9 @@ func main() {
|
||||
|
||||
configure(*configFile)
|
||||
|
||||
router := mux.NewRouter()
|
||||
router.HandleFunc("/avatar", pageRequestHandler)
|
||||
router.HandleFunc("/avatar/{id}", requestHandler)
|
||||
router := http.NewServeMux()
|
||||
router.HandleFunc("GET /avatar", pageRequestHandler)
|
||||
router.HandleFunc("GET /avatar/{id}", requestHandler)
|
||||
log.Printf("Starting on port %d ...\n", *port)
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), router))
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import (
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
//go:embed testdata/1a79a4d60de6718e8e5b326e338ae533_v1.png
|
||||
@ -26,8 +24,8 @@ var gh2 []byte
|
||||
//go:embed testdata/1a79a4d60de6718e8e5b326e338ae533_s40.png
|
||||
var s40 []byte
|
||||
|
||||
func testRouter() *mux.Router {
|
||||
router := mux.NewRouter()
|
||||
func testRouter() *http.ServeMux {
|
||||
router := http.NewServeMux()
|
||||
router.HandleFunc("/avatar/{id}", requestHandler)
|
||||
return router
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user