MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / BuildRouter

Method BuildRouter

imgproxy.go:162–188  ·  view source on GitHub ↗

BuildRouter sets up the HTTP routes and middleware

()

Source from the content-addressed store, hash-verified

160
161// BuildRouter sets up the HTTP routes and middleware
162func (i *Imgproxy) BuildRouter() (*server.Router, error) {
163 r, err := server.NewRouter(&i.config.Server, i.monitoring, i.errorReporter)
164 if err != nil {
165 return nil, err
166 }
167
168 r.GET("/", i.handlers.Landing.Execute)
169 r.GET("", i.handlers.Landing.Execute)
170
171 r.GET(faviconPath, r.NotFoundHandler).Silent()
172 r.GET(healthPath, i.handlers.Health.Execute).Silent()
173 r.GET(wellKnownPath, r.NotFoundHandler).Silent()
174
175 if i.config.Server.HealthCheckPath != "" {
176 r.GET(i.config.Server.HealthCheckPath, i.handlers.Health.Execute).Silent()
177 }
178
179 r.GET(
180 "/*", i.handlers.Processing.Execute,
181 r.WithSecret, r.WithCORS, r.WithPanic, r.WithReportError, r.WithMonitoring,
182 )
183
184 r.HEAD("/*", r.OkHandler, r.WithCORS)
185 r.OPTIONS("/*", r.OkHandler, r.WithCORS)
186
187 return r, nil
188}
189
190// StartServer runs the imgproxy server. This function blocks until the context is cancelled.
191// If hasStarted is not nil, it will be notified with the server address once

Callers 1

StartServerMethod · 0.95

Calls 5

GETMethod · 0.95
HEADMethod · 0.95
OPTIONSMethod · 0.95
NewRouterFunction · 0.92
SilentMethod · 0.80

Tested by

no test coverage detected