Skip to content

Commit

Permalink
add mock ids to support client hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
WillPCowan committed Aug 14, 2023
1 parent 8ad984e commit 5cbd7f9
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package main

import (
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"log"
"lorem/api"
"lorem/image"
"lorem/manager"
"net/http"
"os"
"path"

"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)

func init() {
Expand All @@ -20,7 +21,11 @@ func init() {
flags.String("host", "127.0.0.1:8080", "host:port for the HTTP server")
flags.String("dir", "./images", "directory of images")
flags.String("cache", "true", "cache processed files")
flags.String("cdn", "", "cdn domain (works only on cache mode). leave empty to serve the files by app")
flags.String(
"cdn",
"",
"cdn domain (works only on cache mode). leave empty to serve the files by app",
)
flags.String("min-width", "8", "minimum supported width")
flags.String("min-height", "8", "minimum supported height")
flags.String("max-width", "2000", "maximum supported width")
Expand Down Expand Up @@ -49,15 +54,16 @@ func main() {

a := api.New(m, &image.Imaging{}, &api.Options{
CacheFiles: viper.GetBool("cache"),
CDN: viper.GetString("cdn"),
MinWidth: viper.GetInt("min-width"),
MaxWidth: viper.GetInt("max-width"),
MinHeight: viper.GetInt("min-height"),
MaxHeight: viper.GetInt("max-height"),
CDN: viper.GetString("cdn"),
MinWidth: viper.GetInt("min-width"),
MaxWidth: viper.GetInt("max-width"),
MinHeight: viper.GetInt("min-height"),
MaxHeight: viper.GetInt("max-height"),
})

r := mux.NewRouter()
r.HandleFunc("/image/{category}", a.SizeHandler).Methods(http.MethodGet)
r.HandleFunc("/image/{category}/{id}", a.SizeHandler).Methods(http.MethodGet)
r.HandleFunc("/image", a.SizeHandler).Methods(http.MethodGet)
r.PathPrefix("/").HandlerFunc(a.NotFound)

Expand Down

0 comments on commit 5cbd7f9

Please sign in to comment.