|
5 | 5 | "encoding/json" |
6 | 6 | "encoding/xml" |
7 | 7 | "fmt" |
| 8 | + "strings" |
8 | 9 |
|
9 | 10 | blueskyapi "github.com/Preloading/TwitterAPIBridge/bluesky" |
10 | 11 | "github.com/Preloading/TwitterAPIBridge/config" |
@@ -109,6 +110,21 @@ func InitServer(config *config.Config) { |
109 | 110 |
|
110 | 111 | // Users |
111 | 112 | app.Get("/1/users/show.:filetype", user_info) |
| 113 | + app.Get("/1/users/show/*", func(c *fiber.Ctx) error { |
| 114 | + path := c.Params("*") |
| 115 | + lastDotIndex := strings.LastIndex(path, ".") |
| 116 | + |
| 117 | + if lastDotIndex == -1 { |
| 118 | + // No file extension found |
| 119 | + c.Locals("handle", path) |
| 120 | + c.Locals("filetype", "json") // Default to JSON |
| 121 | + } else { |
| 122 | + c.Locals("handle", path[:lastDotIndex]) |
| 123 | + c.Locals("filetype", path[lastDotIndex+1:]) |
| 124 | + } |
| 125 | + |
| 126 | + return user_info(c) |
| 127 | + }) |
112 | 128 | app.Get("/1/users/lookup.:filetype", UsersLookup) |
113 | 129 | app.Post("/1/users/lookup.:filetype", UsersLookup) |
114 | 130 | app.Get("/1/friendships/lookup.:filetype", UserRelationships) |
@@ -182,6 +198,9 @@ func MobileClientApiDecider(c *fiber.Ctx) error { |
182 | 198 |
|
183 | 199 | func EncodeAndSend(c *fiber.Ctx, data interface{}) error { |
184 | 200 | encodeType := c.Params("filetype") |
| 201 | + if encodeType == "" { |
| 202 | + encodeType = c.Locals("filetype").(string) |
| 203 | + } |
185 | 204 | switch encodeType { |
186 | 205 | case "xml": |
187 | 206 | // Encode the data to XML |
|
0 commit comments