Ocean/WebContent/Handler.go

29 lines
909 B
Go
Raw Permalink Normal View History

package WebContent
import (
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"github.com/SommerEngineering/Ocean/Shutdown"
"net/http"
"strings"
)
2015-06-17 15:44:52 +00:00
// The handler to deliver web framework files e.g. jQuery, Bootstrap, etc.
func HandlerDeliverFramework(response http.ResponseWriter, request *http.Request) {
2015-06-17 15:44:52 +00:00
// If the system is going down, send an error:
if Shutdown.IsDown() {
http.NotFound(response, request)
return
}
2015-06-17 15:44:52 +00:00
// Replace the prefix:
path := strings.Replace(request.URL.Path, "/framework/", "", 1)
sendError := SendContent(response, path)
if sendError != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameWRITE, `Was not able to send the desired web content file.`, request.URL.Path, sendError.Error())
http.NotFound(response, request)
}
}