Skip to content

Commit c3d6824

Browse files
committed
Add sub-url replacement to kitspace route
1 parent 2d26aa8 commit c3d6824

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

routers/kitspace.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ package routers
22

33
import (
44
"bytes"
5-
"code.gitea.io/gitea/models"
6-
"code.gitea.io/gitea/modules/context"
75
"encoding/json"
86
"fmt"
9-
"github.com/go-macaron/csrf"
10-
"github.com/go-macaron/session"
117
"io/ioutil"
128
"net/http"
9+
"path"
1310
"strings"
1411

1512
"gitea.com/macaron/csrf"
@@ -27,12 +24,19 @@ type Message struct {
2724
}
2825

2926
func Kitspace(ctx *context.Context, sess session.Store, x csrf.CSRF) []byte {
30-
m := Message{User: ctx.User, Csrf: x.GetToken(), Route: strings.Replace(ctx.Link, "/kitspace", "", 1)}
31-
fmt.Printf("%+v\n", ctx)
27+
m := Message{
28+
User: ctx.User,
29+
Csrf: x.GetToken(),
30+
Route: strings.Replace(
31+
ctx.Link,
32+
path.Join(setting.AppSubURL, "/kitspace"), "", 1,
33+
),
34+
}
3235
b, err := json.Marshal(m)
3336
if err != nil {
3437
panic(err)
3538
}
39+
fmt.Println(string(b))
3640
url := "http://localhost:3001/"
3741
resp, err := http.Post(url, "application/json", bytes.NewBuffer(b))
3842
if err != nil {

0 commit comments

Comments
 (0)