uniform names of handler functions

This commit is contained in:
Liang Ding 2015-03-09 14:16:46 +08:00
parent 04888ede4c
commit 46e187a1a8
7 changed files with 45 additions and 45 deletions

View File

@ -23,8 +23,8 @@ import (
"github.com/b3log/wide/util"
)
// GetZip handles request of retrieving zip file.
func GetZip(w http.ResponseWriter, r *http.Request) {
// GetZipHandler handles request of retrieving zip file.
func GetZipHandler(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
path := q["path"][0]
@ -49,8 +49,8 @@ func GetZip(w http.ResponseWriter, r *http.Request) {
os.Remove(path)
}
// CreateZip handles request of creating zip.
func CreateZip(w http.ResponseWriter, r *http.Request) {
// CreateZipHandler handles request of creating zip.
func CreateZipHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)

View File

@ -68,11 +68,11 @@ func initAPINode() {
walk(apiPath, apiNode, false, false, true)
}
// GetFiles handles request of constructing user workspace file tree.
// GetFilesHandler handles request of constructing user workspace file tree.
//
// The Go API source code package also as a child node,
// so that users can easily view the Go API source code in file tree.
func GetFiles(w http.ResponseWriter, r *http.Request) {
func GetFilesHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetGzJSON(w, r, data)
@ -113,8 +113,8 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
data["root"] = root
}
// RefreshDirectory handles request of refresh a directory of file tree.
func RefreshDirectory(w http.ResponseWriter, r *http.Request) {
// RefreshDirectoryHandler handles request of refresh a directory of file tree.
func RefreshDirectoryHandler(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
path := r.FormValue("path")
@ -132,8 +132,8 @@ func RefreshDirectory(w http.ResponseWriter, r *http.Request) {
w.Write(data)
}
// GetFile handles request of opening file by editor.
func GetFile(w http.ResponseWriter, r *http.Request) {
// GetFileHandler handles request of opening file by editor.
func GetFileHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)
@ -192,8 +192,8 @@ func GetFile(w http.ResponseWriter, r *http.Request) {
}
}
// SaveFile handles request of saving file.
func SaveFile(w http.ResponseWriter, r *http.Request) {
// SaveFileHandler handles request of saving file.
func SaveFileHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)
@ -234,8 +234,8 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
}
}
// NewFile handles request of creating file or directory.
func NewFile(w http.ResponseWriter, r *http.Request) {
// NewFileHandler handles request of creating file or directory.
func NewFileHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)
@ -269,8 +269,8 @@ func NewFile(w http.ResponseWriter, r *http.Request) {
}
}
// RemoveFile handles request of removing file or directory.
func RemoveFile(w http.ResponseWriter, r *http.Request) {
// RemoveFileHandler handles request of removing file or directory.
func RemoveFileHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)
@ -296,8 +296,8 @@ func RemoveFile(w http.ResponseWriter, r *http.Request) {
}
}
// RenameFile handles request of renaming file or directory.
func RenameFile(w http.ResponseWriter, r *http.Request) {
// RenameFileHandler handles request of renaming file or directory.
func RenameFileHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)
@ -336,8 +336,8 @@ func (f foundPaths) Len() int { return len(f) }
func (f foundPaths) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
func (f foundPaths) Less(i, j int) bool { return f[i].score > f[j].score }
// Find handles request of find files under the specified directory with the specified filename pattern.
func Find(w http.ResponseWriter, r *http.Request) {
// FindHandler handles request of find files under the specified directory with the specified filename pattern.
func FindHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)
@ -384,8 +384,8 @@ func Find(w http.ResponseWriter, r *http.Request) {
data["founds"] = founds
}
// SearchText handles request of searching files under the specified directory with the specified keyword.
func SearchText(w http.ResponseWriter, r *http.Request) {
// SearchTextHandler handles request of searching files under the specified directory with the specified keyword.
func SearchTextHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)

View File

@ -65,8 +65,8 @@ func handleUploads(r *http.Request, dir string) (fileInfos []*fileInfo) {
return
}
// Upload handles request of file upload.
func Upload(w http.ResponseWriter, r *http.Request) {
// UploadHandler handles request of file upload.
func UploadHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)

View File

@ -32,8 +32,8 @@ type element struct {
Ch int
}
// GetOutline gets outfile of a go file.
func GetOutline(w http.ResponseWriter, r *http.Request) {
// GetOutlineHandler gets outfile of a go file.
func GetOutlineHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)

30
main.go
View File

@ -113,7 +113,7 @@ func main() {
// session
http.HandleFunc(conf.Wide.Context+"/session/ws", handlerWrapper(session.WSHandler))
http.HandleFunc(conf.Wide.Context+"/session/save", handlerWrapper(session.SaveContent))
http.HandleFunc(conf.Wide.Context+"/session/save", handlerWrapper(session.SaveContentHandler))
// run
http.HandleFunc(conf.Wide.Context+"/build", handlerWrapper(output.BuildHandler))
@ -126,23 +126,23 @@ func main() {
http.HandleFunc(conf.Wide.Context+"/output/ws", handlerWrapper(output.WSHandler))
// file tree
http.HandleFunc(conf.Wide.Context+"/files", handlerWrapper(file.GetFiles))
http.HandleFunc(conf.Wide.Context+"/file/refresh", handlerWrapper(file.RefreshDirectory))
http.HandleFunc(conf.Wide.Context+"/file", handlerWrapper(file.GetFile))
http.HandleFunc(conf.Wide.Context+"/file/save", handlerWrapper(file.SaveFile))
http.HandleFunc(conf.Wide.Context+"/file/new", handlerWrapper(file.NewFile))
http.HandleFunc(conf.Wide.Context+"/file/remove", handlerWrapper(file.RemoveFile))
http.HandleFunc(conf.Wide.Context+"/file/rename", handlerWrapper(file.RenameFile))
http.HandleFunc(conf.Wide.Context+"/file/search/text", handlerWrapper(file.SearchText))
http.HandleFunc(conf.Wide.Context+"/file/find/name", handlerWrapper(file.Find))
http.HandleFunc(conf.Wide.Context+"/files", handlerWrapper(file.GetFilesHandler))
http.HandleFunc(conf.Wide.Context+"/file/refresh", handlerWrapper(file.RefreshDirectoryHandler))
http.HandleFunc(conf.Wide.Context+"/file", handlerWrapper(file.GetFileHandler))
http.HandleFunc(conf.Wide.Context+"/file/save", handlerWrapper(file.SaveFileHandler))
http.HandleFunc(conf.Wide.Context+"/file/new", handlerWrapper(file.NewFileHandler))
http.HandleFunc(conf.Wide.Context+"/file/remove", handlerWrapper(file.RemoveFileHandler))
http.HandleFunc(conf.Wide.Context+"/file/rename", handlerWrapper(file.RenameFileHandler))
http.HandleFunc(conf.Wide.Context+"/file/search/text", handlerWrapper(file.SearchTextHandler))
http.HandleFunc(conf.Wide.Context+"/file/find/name", handlerWrapper(file.FindHandler))
// outline
http.HandleFunc(conf.Wide.Context+"/outline", handlerWrapper(file.GetOutline))
http.HandleFunc(conf.Wide.Context+"/outline", handlerWrapper(file.GetOutlineHandler))
// file export/import
http.HandleFunc(conf.Wide.Context+"/file/zip/new", handlerWrapper(file.CreateZip))
http.HandleFunc(conf.Wide.Context+"/file/zip", handlerWrapper(file.GetZip))
http.HandleFunc(conf.Wide.Context+"/file/upload", handlerWrapper(file.Upload))
http.HandleFunc(conf.Wide.Context+"/file/zip/new", handlerWrapper(file.CreateZipHandler))
http.HandleFunc(conf.Wide.Context+"/file/zip", handlerWrapper(file.GetZipHandler))
http.HandleFunc(conf.Wide.Context+"/file/upload", handlerWrapper(file.UploadHandler))
// editor
http.HandleFunc(conf.Wide.Context+"/editor/ws", handlerWrapper(editor.WSHandler))
@ -162,7 +162,7 @@ func main() {
// user
http.HandleFunc(conf.Wide.Context+"/login", handlerWrapper(session.LoginHandler))
http.HandleFunc(conf.Wide.Context+"/logout", handlerWrapper(session.LogoutHandler))
http.HandleFunc(conf.Wide.Context+"/signup", handlerWrapper(session.SignUpUser))
http.HandleFunc(conf.Wide.Context+"/signup", handlerWrapper(session.SignUpUserHandler))
http.HandleFunc(conf.Wide.Context+"/preference", handlerWrapper(session.PreferenceHandler))
// playground

View File

@ -238,8 +238,8 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
}
}
// SaveContent handles request of session content string.
func SaveContent(w http.ResponseWriter, r *http.Request) {
// SaveContentHandler handles request of session content string.
func SaveContentHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data)

View File

@ -223,8 +223,8 @@ func LogoutHandler(w http.ResponseWriter, r *http.Request) {
httpSession.Save(r, w)
}
// SignUpUser handles request of registering user.
func SignUpUser(w http.ResponseWriter, r *http.Request) {
// SignUpUserHandler handles request of registering user.
func SignUpUserHandler(w http.ResponseWriter, r *http.Request) {
if "GET" == r.Method {
// show the user sign up page