函数不执行

package main

import (
    "app/config"
    // "app/controllers"
    // _ "app/utils"
    "fmt"
    "github.com/gorilla/mux"
    "log"
    "net/http"
    "strconv"
)

func main() {
    r := mux.NewRouter()

    http.Handle("/js/", http.FileServer(http.Dir("dist")))
    http.Handle("/css/", http.FileServer(http.Dir("dist")))
    http.Handle("/fonts/", http.FileServer(http.Dir("dist")))
    http.Handle("/imgs/", http.FileServer(http.Dir("dist")))
    http.Handle("/vendor/", http.FileServer(http.Dir("dist")))

    r.HandleFunc("/", Sss)

    http.Handle("/", r)

    if err := http.ListenAndServe(config.ConfigObj.Host+":"+strconv.Itoa(config.ConfigObj.Port), nil); err != nil {
        log.Fatalln("ListenAndServe: ", err)
    }
}

func Sss(w http.ResponseWriter, r *http.Request) {
    fmt.Println("dsdsdsdsdsdss")
}

为什么Sss函数没有执行?

共 1 个回复


fanyang

换成http.HandleFunc

# 0