Compare commits
	
		
			No commits in common. "37d242cde13dcc4eec1581f4e7b14dd18bb2a256" and "abff0ef3baea059db489e582a6236f74281bcef0" have entirely different histories.
		
	
	
		
			37d242cde1
			...
			abff0ef3ba
		
	
		
							
								
								
									
										8
									
								
								hyde.rb
								
								
								
								
							
							
						
						
									
										8
									
								
								hyde.rb
								
								
								
								
							|  | @ -109,7 +109,6 @@ module Hyde | |||
|       @response = response | ||||
|       @handles = {} | ||||
|       @indexlist = [] | ||||
|       @vars = {} | ||||
|     end | ||||
|     attr_reader :request | ||||
|     attr_reader :response | ||||
|  | @ -117,7 +116,6 @@ module Hyde | |||
|     attr_accessor :path | ||||
|     attr_accessor :handles | ||||
|     attr_accessor :indexlist | ||||
|     attr_accessor :vars | ||||
|   end | ||||
| 
 | ||||
|   # Context object with safe path encapsulation | ||||
|  | @ -128,8 +126,6 @@ module Hyde | |||
|       @request = request.request | ||||
|       @response = request.response | ||||
|       @handles = request.handles | ||||
|       @indexlist = request.indexlist | ||||
|       @vars = request.vars | ||||
|     end | ||||
|     undef :path= | ||||
|     undef :filepath= | ||||
|  | @ -241,12 +237,8 @@ module Hyde | |||
|     def handle(code, &block) | ||||
|       @handles[code] = block | ||||
|     end | ||||
|     def preprocess(&block)  | ||||
|       @preprocessor = block | ||||
|     end | ||||
|     def match(request)  | ||||
|       raise Exception, "Not permitted" if @lock_methods | ||||
|       self.instance_exec request, &@preprocessor if @preprocessor | ||||
|       if match? request.path then | ||||
|         match_path = normalize_input(request.path).match(@path) | ||||
|         next_path = match_path[0] | ||||
|  |  | |||
|  | @ -15,18 +15,8 @@ server = Hyde::Server.new Port: 8000 do | |||
|     end | ||||
|   end | ||||
|   path "uploads" do | ||||
|     preprocess { |request| puts request.inspect } | ||||
|     index ["index.html"] | ||||
|     serve ["**/*.md","*.html","**/*.html"], match_full_path: true | ||||
|   end | ||||
|   path ["vars_1","vars_2"] do | ||||
|     preprocess do |request| | ||||
|       request.vars["flag"] = "yes" if request.filepath.match "vars_1" | ||||
|     end | ||||
|     serve "view" do |ctx| | ||||
|       ctx.response.body = "Flag: #{ctx.vars["flag"]}" | ||||
|       ctx.response['Content-Type'] = "text/plain" | ||||
|     end | ||||
|     serve "**/*.md", match_full_path: true | ||||
|     serve ["*.html","**/*.html"], match_full_path: true | ||||
|   end | ||||
| end | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue