github.com/gramework/gramework@v1.8.1-0.20231027140105-82555c9057f5/router_domain.go (about)

     1  // Copyright 2017-present Kirill Danshin and Gramework contributors
     2  // Copyright 2019-present Highload LTD (UK CN: 11893420)
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  
    11  package gramework
    12  
    13  // Domain returns a domain router
    14  func (app *App) Domain(domain string) *Router {
    15  	app.domainListLock.Lock()
    16  	if app.domains[domain] == nil {
    17  		app.domains[domain] = &Router{
    18  			router: newRouter(),
    19  			app:    app,
    20  		}
    21  	}
    22  	app.domainListLock.Unlock()
    23  	return app.domains[domain]
    24  }