File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,23 @@ fn source(req: HttpRequest<State>) -> Result<HttpResponse> {
4343 . get ( "sources" )
4444 . ok_or ( error:: ErrorBadRequest ( "invalid source" ) ) ?;
4545
46+ let path = req. headers ( )
47+ . get ( "x-rewrite-url" )
48+ . map_or ( String :: from ( source_ids) , |header| {
49+ let parts: Vec < & str > = header. to_str ( ) . unwrap ( ) . split ( "." ) . collect ( ) ;
50+ let ( _, parts_without_extension) = parts. split_last ( ) . unwrap ( ) ;
51+ let path_without_extension = parts_without_extension. join ( "." ) ;
52+ let ( _, path_without_leading_slash) = path_without_extension. split_at ( 1 ) ;
53+
54+ String :: from ( path_without_leading_slash)
55+ } ) ;
56+
57+ let conn = req. connection_info ( ) ;
4658 let tiles_url = format ! (
47- "{}/{{z}}/{{x}}/{{y}}.pbf" ,
48- req. url_for( "tilejson" , & [ source_ids] ) . unwrap( )
59+ "{}://{}/{}/{{z}}/{{x}}/{{y}}.pbf" ,
60+ conn. scheme( ) ,
61+ conn. host( ) ,
62+ path
4963 ) ;
5064
5165 let mut tilejson_builder = TileJSONBuilder :: new ( ) ;
You can’t perform that action at this time.
0 commit comments