show error when specified map provider is not current provider when using map image proxy

This commit is contained in:
MaysWind
2023-10-29 14:47:18 +08:00
parent 2984980a54
commit d18e8211ca
3 changed files with 13 additions and 0 deletions
+4
View File
@@ -32,6 +32,10 @@ func (p *MapImageProxy) MapTileImageProxyHandler(c *core.Context) (*httputil.Rev
mapProvider := strings.Replace(c.Query("provider"), "-", "_", -1)
targetUrl := ""
if mapProvider != settings.Container.Current.MapProvider {
return nil, errs.ErrMapProviderNotCurrent
}
if mapProvider == settings.OpenStreetMapProvider {
targetUrl = openStreetMapTileImageUrlFormat
} else if mapProvider == settings.OpenStreetMapHumanitarianStyleProvider {
+1
View File
@@ -28,6 +28,7 @@ const (
NormalSubcategoryCategory = 6
NormalSubcategoryTag = 7
NormalSubcategoryDataManagement = 8
NormalSubcategoryMapProxy = 9
)
// Error represents the specific error returned to user
+8
View File
@@ -0,0 +1,8 @@
package errs
import "net/http"
// Error codes related to map image proxy
var (
ErrMapProviderNotCurrent = NewNormalError(NormalSubcategoryMapProxy, 0, http.StatusBadRequest, "specified map provider is not set")
)