Browse Source

Multiple calls to AddApplicationHandler via the radixLoader now calls

Overwrite on the radix trie.
multiapp-subsubapp
Benjamin Shelton 3 months ago
parent
commit
9144f33497
1 changed files with 1 additions and 5 deletions
  1. +1
    -5
      proxy.go

+ 1
- 5
proxy.go View File

@ -2,7 +2,6 @@ package capstan
import (
"bytes"
"fmt"
"net/http"
"net/url"
"strings"
@ -207,7 +206,6 @@ func NewRadixLoader(def http.Handler) *radixLoader {
}
func (r *radixLoader) AddApplicationHandler(uri string, handler http.Handler) error {
fmt.Println("AddApplicationLoader():", uri, handler)
p, err := url.Parse("url://" + uri)
if err != nil {
return err
@ -217,14 +215,13 @@ func (r *radixLoader) AddApplicationHandler(uri string, handler http.Handler) er
uri = uri[:len(uri)-1]
}
if h := r.trie.Lookup(uri); h != nil {
return ErrAppHandlerAlreadyAdded
r.trie.Overwrite(uri, handler)
}
r.trie.Insert(uri, handler)
return nil
}
func (r *radixLoader) Handler(uri url.URL) (http.Handler, bool) {
fmt.Println("Handler():", uri)
u := uri.String()[2:]
// We don't include the trailing slash here since attached handlers should
@ -235,7 +232,6 @@ func (r *radixLoader) Handler(uri url.URL) (http.Handler, bool) {
handler := r.trie.LongestMatch(u)
if handler == nil {
fmt.Println("Handler(): handler not found:", uri)
return nil, false
}


Loading…
Cancel
Save