Code Review
/
src
/
xds
/
xds-server.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Needs super user rights using install-agl-sdks.sh
[src/xds/xds-server.git]
/
lib
/
webserver
/
server.go
diff --git
a/lib/webserver/server.go
b/lib/webserver/server.go
index
0905c77
..
8fd7e44
100644
(file)
--- a/
lib/webserver/server.go
+++ b/
lib/webserver/server.go
@@
-1,6
+1,7
@@
package webserver
import (
package webserver
import (
+ "fmt"
"net/http"
"os"
"net/http"
"os"
@@
-99,12
+100,12
@@
func (s *Server) Serve() error {
*/
// Web Application (serve on / )
*/
// Web Application (serve on / )
- idxFile := path.Join(s.cfg.WebAppDir, indexFilename)
+ idxFile := path.Join(s.cfg.
FileConf.
WebAppDir, indexFilename)
if _, err := os.Stat(idxFile); err != nil {
s.log.Fatalln("Web app directory not found, check/use webAppDir setting in config file: ", idxFile)
}
if _, err := os.Stat(idxFile); err != nil {
s.log.Fatalln("Web app directory not found, check/use webAppDir setting in config file: ", idxFile)
}
- s.log.Infof("Serve WEB app dir: %s", s.cfg.WebAppDir)
- s.router.Use(static.Serve("/", static.LocalFile(s.cfg.WebAppDir, true)))
+ s.log.Infof("Serve WEB app dir: %s", s.cfg.
FileConf.
WebAppDir)
+ s.router.Use(static.Serve("/", static.LocalFile(s.cfg.
FileConf.
WebAppDir, true)))
s.webApp = s.router.Group("/", s.serveIndexFile)
{
s.webApp.GET("/")
s.webApp = s.router.Group("/", s.serveIndexFile)
{
s.webApp.GET("/")
@@
-113,7
+114,8
@@
func (s *Server) Serve() error {
// Serve in the background
serveError := make(chan error, 1)
go func() {
// Serve in the background
serveError := make(chan error, 1)
go func() {
- serveError <- http.ListenAndServe(":"+s.cfg.HTTPPort, s.router)
+ fmt.Printf("Web Server running on localhost:%s ...\n", s.cfg.FileConf.HTTPPort)
+ serveError <- http.ListenAndServe(":"+s.cfg.FileConf.HTTPPort, s.router)
}()
// Wait for stop, restart or error signals
}()
// Wait for stop, restart or error signals
@@
-152,12
+154,10
@@
func (s *Server) middlewareXDSDetails() gin.HandlerFunc {
// CORS middleware
func (s *Server) middlewareCORS() gin.HandlerFunc {
return func(c *gin.Context) {
// CORS middleware
func (s *Server) middlewareCORS() gin.HandlerFunc {
return func(c *gin.Context) {
-
if c.Request.Method == "OPTIONS" {
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Allow-Headers", "Content-Type")
if c.Request.Method == "OPTIONS" {
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Allow-Headers", "Content-Type")
- c.Header("Access-Control-Allow-Methods", "POST, DELETE, GET, PUT")
- c.Header("Content-Type", "application/json")
+ c.Header("Access-Control-Allow-Methods", "GET, POST, DELETE")
c.Header("Access-Control-Max-Age", cookieMaxAge)
c.AbortWithStatus(204)
return
c.Header("Access-Control-Max-Age", cookieMaxAge)
c.AbortWithStatus(204)
return