File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,10 @@ import (
14
14
"goirc/internal/summary"
15
15
db "goirc/model"
16
16
"html/template"
17
+ "io"
17
18
"log"
18
19
"net/http"
20
+ "net/url"
19
21
"os"
20
22
"strconv"
21
23
"strings"
@@ -250,6 +252,29 @@ func Serve(db *sqlx.DB, b *bot.Bot) {
250
252
http .Redirect (w , r , note .Text .String , http .StatusSeeOther )
251
253
})
252
254
255
+ r .Get ("/vibe" , func (w http.ResponseWriter , r * http.Request ) {
256
+ contentURL := r .FormValue ("url" )
257
+
258
+ parsedURL , err := url .Parse (contentURL )
259
+ if parsedURL .Host != "gist.githubusercontent.com" {
260
+ http .Error (w , "host not allowed" , http .StatusBadRequest )
261
+ return
262
+ }
263
+
264
+ resp , err := http .Get (parsedURL .String ())
265
+ if err != nil {
266
+ http .Error (w , err .Error (), http .StatusInternalServerError )
267
+ return
268
+ }
269
+ defer resp .Body .Close ()
270
+ bytes , err := io .ReadAll (resp .Body )
271
+ if err != nil {
272
+ http .Error (w , err .Error (), http .StatusInternalServerError )
273
+ return
274
+ }
275
+ w .Write (bytes )
276
+ })
277
+
253
278
r .Group (func (r chi.Router ) {
254
279
r .Use (func (next http.Handler ) http.Handler {
255
280
return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
You can’t perform that action at this time.
0 commit comments