Skip to content

Commit

Permalink
update NewServer
Browse files Browse the repository at this point in the history
  • Loading branch information
dworld committed Nov 6, 2014
1 parent ec9da65 commit d0899d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion context_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (ctx *Context) GetStaticUrl(url string) string {
}

hash := ctx.getStaticFileHash(url)

if hash == "" {
return cfg.StaticHost + url
}
Expand Down
13 changes: 10 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package xingyun
import (
"net/http"

"code.1dmy.com/xyz/logex"
"github.com/gorilla/securecookie"
)

Expand All @@ -21,11 +22,17 @@ type Server struct {

Name string
Logger Logger
SecureCookie securecookie.SecureCookie
SecureCookie *securecookie.SecureCookie
}

func NewServer(router Router, logger Logger) *Server {
return &Server{Router: router, Logger: logger}
func NewServer(config *Config) *Server {
server := &Server{
Router: NewRouter(),
Logger: logex.NewLogger(1),
}
server.StaticDir = http.Dir(config.StaticDir)
server.SecureCookie = securecookie.New([]byte(config.CookieSecret), []byte(config.CookieSecret))
return server
}

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit d0899d6

Please sign in to comment.