diff --git a/lib/anubis.go b/lib/anubis.go index a3b9338..1614279 100644 --- a/lib/anubis.go +++ b/lib/anubis.go @@ -67,14 +67,15 @@ var ( ) type Server struct { - next http.Handler - mux *http.ServeMux - policy *policy.ParsedConfig - OGTags *ogtags.OGTagCache - ed25519Priv ed25519.PrivateKey - hs512Secret []byte - opts Options - store store.Interface + next http.Handler + mux *http.ServeMux + policy *policy.ParsedConfig + OGTags *ogtags.OGTagCache + ed25519Priv ed25519.PrivateKey + hs512Secret []byte + opts Options + store store.Interface + internalPath string } func (s *Server) getTokenKeyfunc() jwt.Keyfunc { diff --git a/lib/config.go b/lib/config.go index 9eab1a3..3ebdd5a 100644 --- a/lib/config.go +++ b/lib/config.go @@ -101,13 +101,14 @@ func New(opts Options) (*Server, error) { anubis.BasePrefix = opts.BasePrefix result := &Server{ - next: opts.Next, - ed25519Priv: opts.ED25519PrivateKey, - hs512Secret: opts.HS512Secret, - policy: opts.Policy, - opts: opts, - OGTags: ogtags.NewOGTagCache(opts.Target, opts.Policy.OpenGraph, opts.Policy.Store), - store: opts.Policy.Store, + next: opts.Next, + ed25519Priv: opts.ED25519PrivateKey, + hs512Secret: opts.HS512Secret, + policy: opts.Policy, + opts: opts, + OGTags: ogtags.NewOGTagCache(opts.Target, opts.Policy.OpenGraph, opts.Policy.Store), + store: opts.Policy.Store, + internalPath: opts.BasePrefix + anubis.StaticPath, } mux := http.NewServeMux() diff --git a/lib/http.go b/lib/http.go index 46f97e3..9b2fbe5 100644 --- a/lib/http.go +++ b/lib/http.go @@ -200,7 +200,7 @@ func (s *Server) respondWithStatus(w http.ResponseWriter, r *http.Request, msg s } func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { - switch strings.HasPrefix(r.URL.Path, anubis.StaticPath) { + switch strings.HasPrefix(r.URL.Path, s.internalPath) { case true: s.mux.ServeHTTP(w, r) case false: