_ lists
parent
e4451923e9
commit
5a0f567da3
|
|
@ -201,7 +201,22 @@ func pushMeta(r *http.Request, k, v string) {
|
|||
}
|
||||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.Pre(s.Proxy)(w, r)
|
||||
foo := s.Proxy
|
||||
if strings.Split(r.Host, ".")[0] == "_" {
|
||||
keys := s.db.Keys(nsRouting)
|
||||
hostURL := map[string]string{}
|
||||
for _, key := range keys {
|
||||
u, _ := s.lookup(key)
|
||||
if u != nil {
|
||||
hostURL[key] = u.String()
|
||||
}
|
||||
}
|
||||
json.NewEncoder(w).Encode(map[string]any{
|
||||
"hostsToURLs": hostURL,
|
||||
})
|
||||
return
|
||||
}
|
||||
s.Pre(foo)(w, r)
|
||||
}
|
||||
|
||||
type corsResponseWriter struct {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package storage
|
|||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable"
|
||||
)
|
||||
|
||||
|
|
@ -10,5 +11,6 @@ var ErrNotFound = errors.New("not found")
|
|||
type DB interface {
|
||||
Get(string, string, packable.Packable) error
|
||||
Set(string, string, packable.Packable) error
|
||||
Keys(string) []string
|
||||
Close() error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package storage
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable"
|
||||
)
|
||||
|
||||
|
|
@ -40,6 +41,15 @@ func (m Map) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m Map) Keys(ns string) []string {
|
||||
m2, _ := m[ns]
|
||||
result := make([]string, 0, len(m2))
|
||||
for k := range m2 {
|
||||
result = append(result, k)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (m Map) Get(ns, key string, value packable.Packable) error {
|
||||
if _, ok := m[ns]; !ok {
|
||||
m[ns] = make(map[string][]byte)
|
||||
|
|
|
|||
Loading…
Reference in New Issue