File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,8 @@ export FERRET_SEARCH_TIMEOUT=5000ms
147
147
# HTTP address for the UI and the REST API
148
148
# Default is :3030
149
149
export FERRET_LISTEN_ADDRESS=:3030
150
+ # A URL path prefix for the UI
151
+ FERRET_LISTEN_PATHPREFIX=
150
152
# A comma separated list of providers
151
153
# Default value is automatically determined from the ENV variables
152
154
export FERRET_LISTEN_PROVIDERS=
Original file line number Diff line number Diff line change 27
27
28
28
// Options represents options
29
29
type Options struct {
30
- listenAddr string
31
- providersList string
30
+ listenAddr string
31
+ listenPathPrefix string
32
+ providersList string
32
33
}
33
34
34
35
// httpError represents an HTTP error
@@ -53,6 +54,9 @@ func init() {
53
54
if e := os .Getenv ("FERRET_LISTEN_ADDRESS" ); e != "" {
54
55
options .listenAddr = e
55
56
}
57
+ if e := os .Getenv ("FERRET_LISTEN_PATHPREFIX" ); e != "" {
58
+ options .listenPathPrefix = e
59
+ }
56
60
if e := os .Getenv ("FERRET_LISTEN_PROVIDERS" ); e != "" {
57
61
options .providersList = e
58
62
}
@@ -77,9 +81,10 @@ func init() {
77
81
// Listen initializes HTTP handlers and listens for the requests
78
82
func Listen () {
79
83
// Init handlers
80
- http .Handle ("/" , assets .PublicHandler ())
81
- http .HandleFunc ("/search" , SearchHandler )
82
- http .HandleFunc ("/providers" , ProvidersHandler )
84
+ lpp := strings .TrimRight (options .listenPathPrefix , "/" )
85
+ http .Handle ("/" , http .StripPrefix (options .listenPathPrefix , assets .PublicHandler ()))
86
+ http .HandleFunc (fmt .Sprintf ("%s/search" , lpp ), SearchHandler )
87
+ http .HandleFunc (fmt .Sprintf ("%s/providers" , lpp ), ProvidersHandler )
83
88
84
89
// Listen
85
90
log .Printf ("listening on %s" , options .listenAddr )
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ var app = function app() {
18
18
// Init vars
19
19
var serverUrl = location . protocol + '//' + location . hostname + ':' + location . port ;
20
20
serverUrl = ( location . protocol == 'file:' ) ? 'http://localhost:3030' : serverUrl ; // for debug
21
+ var appPath = location . pathname || '/' ;
21
22
22
23
// init initializes the app
23
24
function init ( ) {
@@ -99,7 +100,7 @@ var app = function app() {
99
100
// getProviders gets the provider list
100
101
function getProviders ( ) {
101
102
return $ . ajax ( {
102
- url : serverUrl + '/ providers',
103
+ url : serverUrl + appPath + ' providers',
103
104
dataType : 'jsonp' ,
104
105
method : 'GET' ,
105
106
} ) . promise ( ) ;
@@ -108,7 +109,7 @@ var app = function app() {
108
109
// search makes a search by the given provider and keyword
109
110
function search ( provider , keyword ) {
110
111
return $ . ajax ( {
111
- url : serverUrl + '/ search',
112
+ url : serverUrl + appPath + ' search',
112
113
dataType : 'jsonp' ,
113
114
method : 'GET' ,
114
115
data : {
You can’t perform that action at this time.
0 commit comments