Admin Interface & Handlers

* In Progress, Not Done Yet
+ Added Handlers to cover public and admin handlers
+ Added WebServer
+ InitHandlers used the new class
This commit is contained in:
Thorsten committed 2014-11-06 17:49:04 +01:00
1 parent f33f7b5c29
commit c1e8ca4b07
10 files changed
+126 -23

No files matched your search

-5
View File
@@ -1,5 +0,0 @@
package System
type ICCCStartUpMessage struct {
IPAddressAndPort string
}
+7 -7
View File
@@ -2,6 +2,7 @@ package System
import (
"github.com/SommerEngineering/Ocean/ConfigurationDB"
"github.com/SommerEngineering/Ocean/Handlers"
"github.com/SommerEngineering/Ocean/ICCC"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
@@ -9,7 +10,6 @@ import (
"github.com/SommerEngineering/Ocean/Robots"
"github.com/SommerEngineering/Ocean/StaticFiles"
"github.com/SommerEngineering/Ocean/WebContent"
"net/http"
)
func InitHandlers() {
@@ -17,15 +17,15 @@ func InitHandlers() {
initSystem()
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Register now all system handlers.`)
http.HandleFunc(`/framework/`, WebContent.HandlerDeliverFramework)
http.HandleFunc(`/staticFiles/`, StaticFiles.HandlerStaticFiles)
http.HandleFunc(`/next/number`, NumGen.HandlerGetNext)
http.HandleFunc(`/robots.txt`, Robots.HandlerRobots)
http.HandleFunc(`/ICCC`, ICCC.ICCCHandler)
Handlers.AddPublicHandler(`/framework/`, WebContent.HandlerDeliverFramework)
Handlers.AddPublicHandler(`/staticFiles/`, StaticFiles.HandlerStaticFiles)
Handlers.AddPublicHandler(`/next/number`, NumGen.HandlerGetNext)
Handlers.AddPublicHandler(`/robots.txt`, Robots.HandlerRobots)
Handlers.AddPublicHandler(`/ICCC`, ICCC.ICCCHandler)
if ConfigurationDB.Read(`MapStaticFiles2Root`) == "true" {
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `The static files are mapped to the root.`)
http.HandleFunc(`/`, StaticFiles.HandlerMapStaticFiles2Root)
Handlers.AddPublicHandler(`/`, StaticFiles.HandlerMapStaticFiles2Root)
}
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Done with registering all system handler.`)
+2 -15
View File
@@ -1,22 +1,9 @@
package System
import (
"github.com/SommerEngineering/Ocean/ICCC"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"github.com/SommerEngineering/Ocean/Tools"
"net/http"
"github.com/SommerEngineering/Ocean/WebServer"
)
func StartAndBlockForever() {
ipAddressPort := Tools.LocalIPAddressAndPort()
// Tell the whole cluster, that we are up and ready:
data := ICCCStartUpMessage{}
data.IPAddressAndPort = ipAddressPort
ICCC.WriteMessage2All(ICCC.ChannelSYSTEM, `System::Start`, data)
// Start and block:
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `Web server is now listening.`, `Configuration for hostname and port.`, ipAddressPort)
http.ListenAndServe(ipAddressPort, nil)
WebServer.Start()
}