mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
pointers to Runtime!
This commit is contained in:
parent
792c3e2ce8
commit
27640dffc4
15 changed files with 315 additions and 82 deletions
|
@ -28,7 +28,7 @@ import (
|
|||
)
|
||||
|
||||
type middleware struct {
|
||||
Runtime env.Runtime
|
||||
Runtime *env.Runtime
|
||||
}
|
||||
|
||||
func (m *middleware) cors(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||
|
@ -194,7 +194,7 @@ func (m *middleware) Authorize(w http.ResponseWriter, r *http.Request, next http
|
|||
|
||||
// Certain assets/URL do not require authentication.
|
||||
// Just stops the log files being clogged up with failed auth errors.
|
||||
func preAuthorizeStaticAssets(rt env.Runtime, r *http.Request) bool {
|
||||
func preAuthorizeStaticAssets(rt *env.Runtime, r *http.Request) bool {
|
||||
if strings.ToLower(r.URL.Path) == "/" ||
|
||||
strings.ToLower(r.URL.Path) == "/validate" ||
|
||||
strings.ToLower(r.URL.Path) == "/favicon.ico" ||
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
)
|
||||
|
||||
// RegisterEndpoints register routes for serving API endpoints
|
||||
func RegisterEndpoints(rt env.Runtime) {
|
||||
func RegisterEndpoints(rt *env.Runtime) {
|
||||
//**************************************************
|
||||
// Non-secure routes
|
||||
//**************************************************
|
||||
|
|
|
@ -62,7 +62,7 @@ func (s routeSorter) Less(i, j int) bool {
|
|||
return s[i].ord < s[j].ord
|
||||
}
|
||||
|
||||
func routesKey(rt env.Runtime, prefix, path string, methods, queries []string) (string, error) {
|
||||
func routesKey(rt *env.Runtime, prefix, path string, methods, queries []string) (string, error) {
|
||||
rd := routeDef{
|
||||
Prefix: prefix,
|
||||
Path: path,
|
||||
|
@ -79,7 +79,7 @@ func routesKey(rt env.Runtime, prefix, path string, methods, queries []string) (
|
|||
}
|
||||
|
||||
// Add an endpoint to those that will be processed when Serve() is called.
|
||||
func Add(rt env.Runtime, prefix, path string, methods, queries []string, endPtFn RouteFunc) error {
|
||||
func Add(rt *env.Runtime, prefix, path string, methods, queries []string, endPtFn RouteFunc) error {
|
||||
k, e := routesKey(rt, prefix, path, methods, queries)
|
||||
if e != nil {
|
||||
return e
|
||||
|
@ -89,7 +89,7 @@ func Add(rt env.Runtime, prefix, path string, methods, queries []string, endPtFn
|
|||
}
|
||||
|
||||
// Remove an endpoint.
|
||||
func Remove(rt env.Runtime, prefix, path string, methods, queries []string) error {
|
||||
func Remove(rt *env.Runtime, prefix, path string, methods, queries []string) error {
|
||||
k, e := routesKey(rt, prefix, path, methods, queries)
|
||||
if e != nil {
|
||||
return e
|
||||
|
@ -99,7 +99,7 @@ func Remove(rt env.Runtime, prefix, path string, methods, queries []string) erro
|
|||
}
|
||||
|
||||
// BuildRoutes returns all matching routes for specified scope.
|
||||
func BuildRoutes(rt env.Runtime, prefix string) *mux.Router {
|
||||
func BuildRoutes(rt *env.Runtime, prefix string) *mux.Router {
|
||||
var rs routeSorter
|
||||
for k, v := range routes {
|
||||
var rd routeDef
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
var testHost string // used during automated testing
|
||||
|
||||
// Start router to handle all HTTP traffic.
|
||||
func Start(rt env.Runtime, ready chan struct{}) {
|
||||
func Start(rt *env.Runtime, ready chan struct{}) {
|
||||
|
||||
err := plugins.LibSetup()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue