我在使用库mux-logrus运行时遇到问题,但是使用该库时,输入中出现了这种意外的NUL,我使用的库怎么了?
package main
import (
"Go-SMSBlasts/app"
"Go-SMSBlasts/controllers"
"fmt"
"github.com/gorilla/mux"
"github.com/pytimer/mux-logrus"
"net/http"
"os"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/api/user/new", controllers.CreateAccount).Methods(http.MethodPost)
r.HandleFunc("/api/user/login", controllers.Authenticate).Methods(http.MethodPost)
r.HandleFunc("/api/user/getAllData",controllers.PostSMSBlastBySequenceIDAndMobilePhone).Methods(http.MethodPost)
r.HandleFunc("/api/user/insert",controllers.InsertSMSBlast).Methods(http.MethodPost)
r.Use(app.JwtAuthentication) //attach JWT auth middleware
//logrus
r.Use(muxlogrus.NewLogger().Middleware)
port := os.Getenv("PORT") //Get port from .env file, we did not specify any port so this should return an empty string when tested locally
if port == "" {
port = "8000" //localhost
}
fmt.Println(port)
err := http.ListenAndServe(":" + port, r) //Launch the app, visit localhost:8000/api
if err != nil {
fmt.Print(err)
}
}