3333 ExceptionHandler ExceptionHandle
3434 NotFoundHandler StandardHandle // NotFoundHandler 支持自定义404处理代码能力
3535 MethodNotAllowedHandler StandardHandle // MethodNotAllowedHandler fixed for #64 增加MethodNotAllowed自定义处理
36- AppContext * core.ItemContext
36+ Items * core.ItemContext
3737 middlewareMap map [string ]MiddlewareFunc
3838 middlewareMutex * sync.RWMutex
3939 StartMode string
5252
5353const (
5454 DefaultHTTPPort = 8080 //DefaultHTTPPort default http port; fixed for #70 UPDATE default http port 80 to 8080
55+ DefaultConfigSetGroupName = "default"
5556 RunMode_Development = "development"
5657 RunMode_Production = "production"
5758
@@ -65,7 +66,7 @@ func New() *DotWeb {
6566 HttpServer : NewHttpServer (),
6667 OfflineServer : servers .NewOfflineServer (),
6768 Middlewares : make ([]Middleware , 0 ),
68- AppContext : core .NewItemContext (),
69+ Items : core .NewItemContext (),
6970 Config : config .NewConfig (),
7071 middlewareMap : make (map [string ]MiddlewareFunc ),
7172 middlewareMutex : new (sync.RWMutex ),
@@ -122,6 +123,46 @@ func (app *DotWeb) SetCache(ca cache.Cache) {
122123 app .cache = ca
123124}
124125
126+ // IncludeConfigSetXML include ConfigSet xml file to Dotweb.Items
127+ // same key will cover oldest value
128+ func (app * DotWeb ) IncludeConfigSetXML (configFile string ) error {
129+ item , err := config .ParseConfigSetXML (configFile )
130+ if err != nil {
131+ return err
132+ }
133+ for k ,v := range item .GetCurrentMap (){
134+ app .Items .Set (k , v )
135+ }
136+ return nil
137+ }
138+
139+ // IncludeConfigSetJSON include ConfigSet json file to Dotweb.Items
140+ // same key will cover oldest value
141+ func (app * DotWeb ) IncludeConfigSetJSON (configFile string ) error {
142+ item , err := config .ParseConfigSetXML (configFile )
143+ if err != nil {
144+ return err
145+ }
146+ for k ,v := range item .GetCurrentMap (){
147+ app .Items .Set (k , v )
148+ }
149+ return nil
150+ }
151+
152+ // IncludeConfigSetYaml include ConfigSet ymal file to Dotweb.Items
153+ // same key will cover oldest value
154+ func (app * DotWeb ) IncludeConfigSetYaml (configFile string ) error {
155+ item , err := config .ParseConfigSetXML (configFile )
156+ if err != nil {
157+ return err
158+ }
159+ for k ,v := range item .GetCurrentMap (){
160+ app .Items .Set (k , v )
161+ }
162+ return nil
163+ }
164+
165+
125166// RunMode current app run mode, if not set, default set RunMode_Development
126167func (app * DotWeb ) RunMode () string {
127168 if app .Config .App .RunMode != RunMode_Development && app .Config .App .RunMode != RunMode_Production {
0 commit comments