Add documentation
This commit is contained in:
1 parent
69d0bdabf4
commit
6dab89a1d4
144 files changed
+1107
-549
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/SommerEngineering/Ocean/BinaryAssets/SourceCodePro"
|
||||
)
|
||||
|
||||
// Reads the content for a file.
|
||||
func GetData(filename string) (data []byte) {
|
||||
if obj, err := SourceCodePro.Asset(filename); err != nil {
|
||||
return
|
||||
|
||||
@@ -10,8 +10,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Handler to access the binary assets from the web.
|
||||
func HandlerBinaryAssets(response http.ResponseWriter, request *http.Request) {
|
||||
|
||||
// Case: The server is going down.
|
||||
if Shutdown.IsDown() {
|
||||
http.NotFound(response, request)
|
||||
return
|
||||
@@ -31,12 +33,14 @@ func HandlerBinaryAssets(response http.ResponseWriter, request *http.Request) {
|
||||
fileType = mimeType.MimeType
|
||||
}
|
||||
|
||||
// Case: No MIME type determined?
|
||||
if fileType == `` {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelSECURITY, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameNOTFOUND, `The mime type is unknown.`, path)
|
||||
http.NotFound(response, request)
|
||||
return
|
||||
}
|
||||
|
||||
// Read the content:
|
||||
contentData := GetData(path)
|
||||
if contentData == nil {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameDATABASE, `The desired file was not found.`, path)
|
||||
@@ -44,6 +48,7 @@ func HandlerBinaryAssets(response http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Write the meta data and the content to the client:
|
||||
fileLenText := fmt.Sprintf(`%d`, len(contentData))
|
||||
response.Header().Add(`Content-Length`, fileLenText)
|
||||
response.Header().Add(`Content-Type`, fileType)
|
||||
|
||||
@@ -5,5 +5,5 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
senderName LM.Sender = `System::BinaryAssets`
|
||||
senderName LM.Sender = `System::BinaryAssets` // This is the name for logging event from this package
|
||||
)
|
||||
Reference in new issue
Block a user