File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## [ 0.1.2]
9+
10+ ### Changed
11+
12+ - Use of ` NamedFile ` to serve a file.
13+
814## [ 0.1.1]
915
1016### Fixed
Original file line number Diff line number Diff line change @@ -192,25 +192,6 @@ async fn serve(
192192
193193 if path. is_file ( ) {
194194 let file = path. clone ( ) ;
195- let extension = file. extension ( ) . unwrap_or_default ( ) ;
196- if extension == "yaml" || extension == "yml" {
197- let content = web:: block ( move || fs:: read_to_string ( path) )
198- . await
199- . map_err ( |err| {
200- err
201- . map_err_context ( || {
202- format ! ( "Failed to read file {}" , file. display( ) )
203- } )
204- . set_status ( StatusCode :: INTERNAL_SERVER_ERROR )
205- } ) ?;
206-
207- return Ok (
208- web:: HttpResponse :: Ok ( )
209- . content_type ( "text/plain" )
210- . content_length ( content. len ( ) as u64 )
211- . body ( content) ,
212- ) ;
213- }
214195 let err_file = file. clone ( ) ;
215196 let res =
216197 web:: block ( move || NamedFile :: open ( file) )
You can’t perform that action at this time.
0 commit comments