Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Server server `json:"server,omitempty"`
Router `json:"router,omitempty"`
Translation `json:"-"`
Templates `json:"templates,omitempty"`
Response `json:"-"`
Language string `json:"language,omitempty"`
CSPPolicy string `json:"csp_policy,omitempty"`
}
App is the main Rufus instance
func (*App) LoadConfigAndRouter ¶
LoadConfigAndRouter loads data from 'config.json' and sets chi router
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a response cache middleware
func (*Cache) Invalidate ¶
Invalidate is used to delete a cache entry
type Middleware ¶
type Middleware struct {
RedirectToNonWWW bool `json:"redirect_to_non_www,omitempty"`
EnableResponseCache bool `json:"enable_response_cache,omitempty"`
Cache responseCache
}
Middleware struct for rufus
type Router ¶
type Router struct {
Mux *chi.Mux `json:"-"`
LanguageMatcher language.Matcher `json:"-"`
RoutesSender chan string `json:"-"`
RoutesReceiver chan http.Handler `json:"-"`
Middleware `json:"middleware,omitempty"`
}
Router contains the router and all needed methods for automated translation
func (*Router) PrependMiddleware ¶
PrependMiddleware is used to add basic middleware to routers
type Templates ¶
type Templates struct {
TemplateFolder string `json:"template_folder,omitempty"`
BaseTemplate string `json:"base_template,omitempty"`
// contains filtered or unexported fields
}
Templates holds cached template files
func (*Templates) CacheFiles ¶
func (t *Templates) CacheFiles(translation Translation) error
CacheFiles processes templates and saves them to the according map
type Translation ¶
type Translation struct {
Amount int `json:"-"`
Languages map[string]int `json:"languages,omitempty"`
Locales map[string]string `json:"locales,omitempty"`
Phrases map[string][]string `json:"phrases,omitempty"`
URL map[string][]string `json:"url,omitempty"`
}
Translation handles all the functionality and data for translating
func (Translation) Translate ¶
func (t Translation) Translate(s, lang string) string
Translate phrase to according language
func (Translation) TranslateURL ¶
func (t Translation) TranslateURL(s, lang string) string
TranslateURL phrase to URL friendly translation
Click to show internal directories.
Click to hide internal directories.