summaryrefslogtreecommitdiff
path: root/contrib/sharedhost
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sharedhost')
-rw-r--r--contrib/sharedhost/replacement.go12
-rw-r--r--contrib/sharedhost/replacement_test.go10
2 files changed, 11 insertions, 11 deletions
diff --git a/contrib/sharedhost/replacement.go b/contrib/sharedhost/replacement.go
index 9267530..9dc3a1e 100644
--- a/contrib/sharedhost/replacement.go
+++ b/contrib/sharedhost/replacement.go
@@ -5,7 +5,7 @@ import (
"crypto/tls"
"net/url"
- "tildegit.org/tjp/gus"
+ sr "tildegit.org/tjp/sliderule"
)
// ReplaceTilde builds a middleware which substitutes a leading '~' in the request path.
@@ -17,9 +17,9 @@ import (
// Typically the replacement should end with a "/", so that the ~ ends up mapping to a
// particular directory on the filesystem. For instance with a replacement string of
// "users/", "domain.com/~jim/index.gmi" maps to "domain.com/users/jim/index.gmi".
-func ReplaceTilde(replacement string) gus.Middleware {
- return func(inner gus.Handler) gus.Handler {
- return gus.HandlerFunc(func(ctx context.Context, request *gus.Request) *gus.Response {
+func ReplaceTilde(replacement string) sr.Middleware {
+ return func(inner sr.Handler) sr.Handler {
+ return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response {
if len(request.Path) > 1 && request.Path[0] == '/' && request.Path[1] == '~' {
request = cloneRequest(request)
request.Path = "/" + replacement + request.Path[2:]
@@ -30,8 +30,8 @@ func ReplaceTilde(replacement string) gus.Middleware {
}
}
-func cloneRequest(start *gus.Request) *gus.Request {
- next := &gus.Request{}
+func cloneRequest(start *sr.Request) *sr.Request {
+ next := &sr.Request{}
*next = *start
next.URL = &url.URL{}
diff --git a/contrib/sharedhost/replacement_test.go b/contrib/sharedhost/replacement_test.go
index 67c3754..9fa9161 100644
--- a/contrib/sharedhost/replacement_test.go
+++ b/contrib/sharedhost/replacement_test.go
@@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert"
- "tildegit.org/tjp/gus"
- "tildegit.org/tjp/gus/contrib/sharedhost"
+ sr "tildegit.org/tjp/sliderule"
+ "tildegit.org/tjp/sliderule/contrib/sharedhost"
)
func TestReplaceTilde(t *testing.T) {
@@ -42,10 +42,10 @@ func TestReplaceTilde(t *testing.T) {
originalPath := u.Path
replacer := sharedhost.ReplaceTilde(test.replacement)
- request := &gus.Request{URL: u}
- handler := replacer(gus.HandlerFunc(func(_ context.Context, request *gus.Request) *gus.Response {
+ request := &sr.Request{URL: u}
+ handler := replacer(sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response {
assert.Equal(t, test.replacedPath, request.Path)
- return &gus.Response{}
+ return &sr.Response{}
}))
handler.Handle(context.Background(), request)