1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00
I love coding unique Iris staff!!!
This commit is contained in:
Gerasimos Maropoulos
2016-10-27 03:17:09 +03:00
parent 6d65c00423
commit d32ae1377c
8 changed files with 503 additions and 30 deletions

21
iris.go
View File

@@ -79,7 +79,7 @@ const (
// IsLongTermSupport flag is true when the below version number is a long-term-support version
IsLongTermSupport = false
// Version is the current version number of the Iris web framework
Version = "5.0.1"
Version = "5.1.0"
banner = ` _____ _
|_ _| (_)
@@ -142,6 +142,7 @@ type (
// FrameworkAPI contains the main Iris Public API
FrameworkAPI interface {
MuxAPI
CacheService
Set(...OptionSetter)
Must(error)
Build()
@@ -175,6 +176,7 @@ type (
// Implements the FrameworkAPI
Framework struct {
*muxAPI
CacheService
// HTTP Server runtime fields is the iris' defined main server, developer can use unlimited number of servers
// note: they're available after .Build, and .Serve/Listen/ListenTLS/ListenLETSENCRYPT/ListenUNIX
ln net.Listener
@@ -193,11 +195,10 @@ type (
sessions sessions.Sessions
serializers serializer.Serializers
templates *templateEngines
// configuration by instance.Logger.Config
Logger *log.Logger
Plugins PluginContainer
Websocket *WebsocketServer
SSH *SSHServer
Logger *log.Logger
Plugins PluginContainer
Websocket *WebsocketServer
SSH *SSHServer
}
)
@@ -231,6 +232,8 @@ func New(setters ...OptionSetter) *Framework {
"url": s.URL,
"urlpath": s.Path,
})
// set the cache service
s.CacheService = newCacheService()
}
// websocket & sessions
@@ -350,6 +353,9 @@ func (s *Framework) Build() {
s.sessions.Set(s.Config.Sessions, sessions.DisableAutoGC(false))
}
// set the cache gc duration and start service
s.CacheService.Start(s.Config.CacheGCDuration)
if s.Config.Websocket.Endpoint != "" {
// register the websocket server and listen to websocket connections when/if $instance.Websocket.OnConnection called by the dev
s.Websocket.RegisterTo(s, s.Config.Websocket)
@@ -1111,6 +1117,9 @@ func SerializeToString(keyOrContentType string, obj interface{}, options ...map[
func (s *Framework) SerializeToString(keyOrContentType string, obj interface{}, options ...map[string]interface{}) string {
res, err := s.serializers.SerializeToString(keyOrContentType, obj, options...)
if err != nil {
if s.Config.IsDevelopment {
s.Logger.Printf("Error on SerializeToString, Key(content-type): %s. Trace: %s\n", keyOrContentType, err)
}
return ""
}
return res