This commit is contained in:
parent
e7a3fa9334
commit
b8507efed3
|
@ -106,7 +106,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := fout.Close(); nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
output, err := cmd.CombinedOutput()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ func GetExprInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var args map[string]interface{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ func GetExprInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|||
output, err := cmd.CombinedOutput()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var args map[string]interface{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
output, err := cmd.CombinedOutput()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) {
|
|||
output, err := cmd.CombinedOutput()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
9
main.go
9
main.go
|
@ -150,6 +150,7 @@ func main() {
|
|||
http.HandleFunc("/notification/ws", handlerWrapper(notification.WSHandler))
|
||||
|
||||
// user
|
||||
http.HandleFunc("/login", handlerWrapper(session.LoginHandler))
|
||||
http.HandleFunc("/logout", handlerWrapper(session.LogoutHandler))
|
||||
http.HandleFunc("/preference", handlerWrapper(session.PreferenceHandler))
|
||||
|
||||
|
@ -219,7 +220,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|||
t, err := template.ParseFiles("views/index.html")
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -279,7 +280,7 @@ func startHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -308,7 +309,7 @@ func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -338,7 +339,7 @@ func aboutHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
output, err := cmd.CombinedOutput()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ package session
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"github.com/b3log/wide/i18n"
|
||||
"html/template"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -141,6 +143,22 @@ func GitHubUserInfo(accessToken string) (ret map[string]interface{}) {
|
|||
return result["data"].(map[string]interface{})
|
||||
}
|
||||
|
||||
// LoginHandler handles request of show login page.
|
||||
func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
model := map[string]interface{}{"conf": conf.Wide, "i18n": i18n.GetAll(conf.Wide.Locale),
|
||||
"locale": conf.Wide.Locale, "ver": conf.WideVersion, "year": time.Now().Year()}
|
||||
|
||||
t, err := template.ParseFiles("views/login.html")
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
t.Execute(w, model)
|
||||
}
|
||||
|
||||
// LogoutHandler handles request of user logout (exit).
|
||||
func LogoutHandler(w http.ResponseWriter, r *http.Request) {
|
||||
result := util.NewResult()
|
||||
|
|
|
@ -74,7 +74,7 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
http.Error(w, err.Error(), 500)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
user.GoBuildArgsForLinux = tmpLinux
|
||||
user.GoBuildArgsForWindows = tmpWindows
|
||||
|
|
|
@ -218,7 +218,7 @@ var playground = {
|
|||
if (!hovered) {
|
||||
$(".menu .share-panel").hide();
|
||||
}
|
||||
}, 500);
|
||||
}, http.StatusInternalServerError;
|
||||
});
|
||||
|
||||
$(".menu .share-panel").hover(function () {
|
||||
|
|
Loading…
Reference in New Issue