Support i.stack.imgur.com (#61)
This commit is contained in:
		
							parent
							
								
									b8d54dede6
								
							
						
					
					
						commit
						f1c058cbfc
					
				
							
								
								
									
										1
									
								
								main.go
								
								
								
								
							
							
						
						
									
										1
									
								
								main.go
								
								
								
								
							| 
						 | 
					@ -77,6 +77,7 @@ func main() {
 | 
				
			||||||
	app.Get("/privacy", pages.HandlePrivacy)
 | 
						app.Get("/privacy", pages.HandlePrivacy)
 | 
				
			||||||
	app.Get("/:postID.gifv", pages.HandleGifv)
 | 
						app.Get("/:postID.gifv", pages.HandleGifv)
 | 
				
			||||||
	app.Get("/:baseName.:extension", pages.HandleMedia)
 | 
						app.Get("/:baseName.:extension", pages.HandleMedia)
 | 
				
			||||||
 | 
						app.Get("/stack/:baseName.:extension", pages.HandleMedia)
 | 
				
			||||||
	app.Get("/:postID", pages.HandlePost)
 | 
						app.Get("/:postID", pages.HandlePost)
 | 
				
			||||||
	app.Get("/:postID/embed", pages.HandleEmbed)
 | 
						app.Get("/:postID/embed", pages.HandleEmbed)
 | 
				
			||||||
	app.Get("/a/:postID", pages.HandlePost)
 | 
						app.Get("/a/:postID", pages.HandlePost)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,11 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func HandleMedia(c *fiber.Ctx) error {
 | 
					func HandleMedia(c *fiber.Ctx) error {
 | 
				
			||||||
	c.Set("Cache-Control", "public,max-age=31557600")
 | 
						c.Set("Cache-Control", "public,max-age=31557600")
 | 
				
			||||||
	return handleMedia(c, "https://i.imgur.com/" + c.Params("baseName") + "." + c.Params("extension"))
 | 
						if strings.HasPrefix(c.Path(), "/stack") {
 | 
				
			||||||
 | 
							return handleMedia(c, "https://i.stack.imgur.com/" + strings.ReplaceAll(c.Params("baseName"), "stack/", "") + "." + c.Params("extension"))
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return handleMedia(c, "https://i.imgur.com/" + c.Params("baseName") + "." + c.Params("extension"))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func HandleUserCover(c *fiber.Ctx) error {
 | 
					func HandleUserCover(c *fiber.Ctx) error {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue