MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / Web

Function Web

src/webserver.go:886–1062  ·  view source on GitHub ↗

Web : Web Server /web/

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

884
885// Web : Web Server /web/
886func Web(w http.ResponseWriter, r *http.Request) {
887
888 var lang = make(map[string]interface{})
889 var err error
890
891 var requestFile = strings.Replace(r.URL.Path, "/web", "html", -1)
892 var content, contentType, file string
893
894 var language LanguageUI
895
896 if Settings.HttpThreadfinDomain != "" {
897 setGlobalDomain(getBaseUrl(Settings.HttpThreadfinDomain, Settings.Port))
898 } else {
899 setGlobalDomain(r.Host)
900 }
901
902 if System.Dev == true {
903 lang, err = loadJSONFileToMap(fmt.Sprintf("html/lang/%s.json", Settings.Language))
904 if err != nil {
905 ShowError(err, 000)
906 }
907 } else {
908 var languageFile = "html/lang/en.json"
909
910 if value, ok := webUI[languageFile].(string); ok {
911 content = GetHTMLString(value)
912 lang = jsonToMap(content)
913 }
914 }
915
916 err = json.Unmarshal([]byte(mapToJSON(lang)), &language)
917 if err != nil {
918 ShowError(err, 000)
919 return
920 }
921
922 if getFilenameFromPath(requestFile) == "html" {
923
924 systemMutex.Lock()
925 if System.ConfigurationWizard == true {
926 file = requestFile + "configuration.html"
927 Settings.AuthenticationWEB = false
928 } else {
929 file = requestFile + "index.html"
930 }
931
932 authenticationWebEnabled := Settings.AuthenticationWEB
933 systemMutex.Unlock()
934
935 if authenticationWebEnabled == true {
936 var username, password, confirm string
937 switch r.Method {
938 case "POST":
939 var allUserData, _ = authentication.GetAllUserData()
940
941 username = r.FormValue("username")
942 password = r.FormValue("password")
943

Callers

nothing calls this directly

Calls 15

GetAllUserDataFunction · 0.92
SetCookieTokenFunction · 0.92
UserAuthenticationFunction · 0.92
setGlobalDomainFunction · 0.85
getBaseUrlFunction · 0.85
loadJSONFileToMapFunction · 0.85
ShowErrorFunction · 0.85
GetHTMLStringFunction · 0.85
jsonToMapFunction · 0.85
httpStatusErrorFunction · 0.85

Tested by

no test coverage detected