Connect to database using md5 auth.
This commit is contained in:
		
							parent
							
								
									1b20816e7b
								
							
						
					
					
						commit
						fac8d8f4f1
					
				
					 1 changed files with 23 additions and 4 deletions
				
			
		|  | @ -39,6 +39,10 @@ | ||||||
| (define -key- (make-parameter #f)) | (define -key- (make-parameter #f)) | ||||||
| (define -user- (make-parameter #f)) | (define -user- (make-parameter #f)) | ||||||
| (define -group- (make-parameter #f)) | (define -group- (make-parameter #f)) | ||||||
|  | (define -db-host- (make-parameter #f)) | ||||||
|  | (define -db-user- (make-parameter #f)) | ||||||
|  | (define -db-name- (make-parameter #f)) | ||||||
|  | (define -db-pass- (make-parameter #f)) | ||||||
| 
 | 
 | ||||||
| (command-line | (command-line | ||||||
|  print-help |  print-help | ||||||
|  | @ -65,7 +69,16 @@ | ||||||
|  (-u (user) "User to run as (if started as root)" |  (-u (user) "User to run as (if started as root)" | ||||||
|      (-user- user)) |      (-user- user)) | ||||||
|  (-g (group) "Group to run as (if started as root)" |  (-g (group) "Group to run as (if started as root)" | ||||||
|      (-group- group))) |      (-group- group)) | ||||||
|  |  (-dh (hostname) "Database hostname" | ||||||
|  |       (-db-host- hostname)) | ||||||
|  |  (-dn (dbname) "Database name" | ||||||
|  |       (-db-name- dbname)) | ||||||
|  |  (-du (dbuser) "Database username" | ||||||
|  |       (-db-user- dbuser)) | ||||||
|  |  (-dp (dbpass) "Database password" | ||||||
|  |       (-db-pass- dbpass)) | ||||||
|  |  ) | ||||||
| 
 | 
 | ||||||
| (define ssl? (and (-certificate-) (-key-) #t)) | (define ssl? (and (-certificate-) (-key-) #t)) | ||||||
| (define port (or (-port-) (if ssl? 443 80))) | (define port (or (-port-) (if ssl? 443 80))) | ||||||
|  | @ -77,9 +90,6 @@ | ||||||
|   (print "  Certificate:" (-certificate-)) |   (print "  Certificate:" (-certificate-)) | ||||||
|   (print "  Key:" (-key-))) |   (print "  Key:" (-key-))) | ||||||
| 
 | 
 | ||||||
| (define dbconn (connect "postgresql:///brmbar")) |  | ||||||
| (print dbconn) |  | ||||||
| 
 |  | ||||||
| (define listener | (define listener | ||||||
|   (if ssl? |   (if ssl? | ||||||
|       (ssl-listen port) |       (ssl-listen port) | ||||||
|  | @ -92,6 +102,14 @@ | ||||||
| (when (and (-user-) (-group-)) | (when (and (-user-) (-group-)) | ||||||
|   (switch-user/group (-user-) (-group-))) |   (switch-user/group (-user-) (-group-))) | ||||||
| 
 | 
 | ||||||
|  | (define dbconn | ||||||
|  |   (connect | ||||||
|  |    `((dbname . ,(-db-name-)) | ||||||
|  |      (host . ,(-db-host-)) | ||||||
|  |      (user . ,(-db-user-)) | ||||||
|  |      (password . ,(-db-pass-))))) | ||||||
|  | (print dbconn) | ||||||
|  | 
 | ||||||
| (define (handle-request-by-path path) | (define (handle-request-by-path path) | ||||||
|   (print (->string path-lst) (length path)) |   (print (->string path-lst) (length path)) | ||||||
|   (define body |   (define body | ||||||
|  | @ -107,6 +125,7 @@ | ||||||
| (handle-not-found | (handle-not-found | ||||||
|  (lambda (path) |  (lambda (path) | ||||||
|    (define upath (string-intersperse (map ->string (cdr (uri-path (request-uri (current-request))))) "/")) |    (define upath (string-intersperse (map ->string (cdr (uri-path (request-uri (current-request))))) "/")) | ||||||
|  |    (print 'log: upath) | ||||||
|    (cond ((equal? upath "") |    (cond ((equal? upath "") | ||||||
| 	  (send-response #:body (frontend-lookup "index.html"))) | 	  (send-response #:body (frontend-lookup "index.html"))) | ||||||
| 	 (else | 	 (else | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue