/* -*- coding:utf-8 -*-
author: cyz
time: 2021/11/19 10:18
*/
package main
import (
"fmt"
"net/http"
)
type indexHandler struct {
content string
}
func (ih *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, ih.content)
}
func main() {
http.Handle("/", &indexHandler{content: "/status/ +节点名称为状态日志文件\n" +
"/node/ +节点名称为具体日志文件"})
f_status := http.FileServer(http.Dir("/data/cn/qhdata/log/kafka/status/"))
http.Handle("/status/", http.StripPrefix("/status/", f_status))
f_node := http.FileServer(http.Dir("/data/cn/qhdata/log/kafka/node/"))
http.Handle("/node/", http.StripPrefix("/node/", f_node))
http.ListenAndServe(":8081", nil)
}
简单http文件服务
最新推荐文章于 2024-03-16 12:35:43 发布