36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
func httpHandleFunc(urlPath string, filepath string, contentType string) {
|
|
logger(readHttpYML() + "/" + urlPath + " <--> " + filepath + " <" + contentType + ">")
|
|
http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) {
|
|
logger(r.Method + " request -> " + readHttpYML() + "/" + urlPath + " <" + contentType + ">")
|
|
|
|
w.Header().Add("Content-Type", contentType)
|
|
|
|
io.WriteString(w, htmlReplacer(fileRead(filepath), urlPath))
|
|
})
|
|
}
|
|
|
|
func httpHandleFuncWithPOST(urlPath string, filepath string, contentType string) {
|
|
logger(readHttpYML() + "/" + urlPath + " <--> " + filepath + " <" + contentType + ">")
|
|
s := new(submit)
|
|
s.data = "null"
|
|
http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method == "POST" {
|
|
err := r.ParseForm()
|
|
errorPanic(err)
|
|
}
|
|
|
|
logger(r.Method + " request -> " + readHttpYML() + "/" + urlPath + " <" + contentType + ">")
|
|
|
|
w.Header().Add("Content-Type", contentType)
|
|
|
|
io.WriteString(w, htmlReplacer(fileRead(filepath), urlPath))
|
|
})
|
|
}
|