@@ -97,39 +97,42 @@ func main() {
97
97
getFileChain := juliet .NewChain (middleware .Upload , middleware .Yubikey , middleware .File )
98
98
99
99
// HTTP Api routes configuration
100
- r := mux .NewRouter ()
101
- r .Handle ("/config" , stdChain .Then (handlers .GetConfiguration )).Methods ("GET" )
102
- r .Handle ("/version" , stdChain .Then (handlers .GetVersion )).Methods ("GET" )
103
- r .Handle ("/upload" , tokenChain .Then (handlers .CreateUpload )).Methods ("POST" )
104
- r .Handle ("/upload/{uploadID}" , authChain .Append (middleware .Upload ).Then (handlers .GetUpload )).Methods ("GET" )
105
- r .Handle ("/upload/{uploadID}" , authChain .Append (middleware .Upload ).Then (handlers .RemoveUpload )).Methods ("DELETE" )
106
- r .Handle ("/file/{uploadID}" , tokenChain .Append (middleware .Upload ).Then (handlers .AddFile )).Methods ("POST" )
107
- r .Handle ("/file/{uploadID}/{fileID}/{filename}" , tokenChain .Append (middleware .Upload , middleware .File ).Then (handlers .AddFile )).Methods ("POST" )
108
- r .Handle ("/file/{uploadID}/{fileID}/{filename}" , authChain .Append (middleware .Upload , middleware .File ).Then (handlers .RemoveFile )).Methods ("DELETE" )
109
- r .Handle ("/file/{uploadID}/{fileID}/{filename}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
110
- r .Handle ("/file/{uploadID}/{fileID}/{filename}/yubikey/{yubikey}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
111
- r .Handle ("/stream/{uploadID}/{fileID}/{filename}" , tokenChain .Append (middleware .Upload , middleware .File ).Then (handlers .AddFile )).Methods ("POST" )
112
- r .Handle ("/stream/{uploadID}/{fileID}/{filename}" , authChain .Append (middleware .Upload , middleware .File ).Then (handlers .RemoveFile )).Methods ("DELETE" )
113
- r .Handle ("/stream/{uploadID}/{fileID}/{filename}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
114
- r .Handle ("/stream/{uploadID}/{fileID}/{filename}/yubikey/{yubikey}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
115
- r .Handle ("/archive/{uploadID}/{filename}" , authChainWithRedirect .Append (middleware .Upload , middleware .Yubikey ).Then (handlers .GetArchive )).Methods ("HEAD" , "GET" )
116
- r .Handle ("/archive/{uploadID}/{filename}/yubikey/{yubikey}" , authChainWithRedirect .Append (middleware .Upload , middleware .Yubikey ).Then (handlers .GetArchive )).Methods ("HEAD" , "GET" )
117
- r .Handle ("/auth/google/login" , authChain .Then (handlers .GoogleLogin )).Methods ("GET" )
118
- r .Handle ("/auth/google/callback" , stdChainWithRedirect .Then (handlers .GoogleCallback )).Methods ("GET" )
119
- r .Handle ("/auth/ovh/login" , authChain .Then (handlers .OvhLogin )).Methods ("GET" )
120
- r .Handle ("/auth/ovh/callback" , stdChainWithRedirect .Then (handlers .OvhCallback )).Methods ("GET" )
121
- r .Handle ("/auth/logout" , authChain .Then (handlers .Logout )).Methods ("GET" )
122
- r .Handle ("/me" , authChain .Then (handlers .UserInfo )).Methods ("GET" )
123
- r .Handle ("/me" , authChain .Then (handlers .DeleteAccount )).Methods ("DELETE" )
124
- r .Handle ("/me/token" , authChain .Then (handlers .CreateToken )).Methods ("POST" )
125
- r .Handle ("/me/token/{token}" , authChain .Then (handlers .RevokeToken )).Methods ("DELETE" )
126
- r .Handle ("/me/uploads" , authChain .Then (handlers .GetUserUploads )).Methods ("GET" )
127
- r .Handle ("/me/uploads" , authChain .Then (handlers .RemoveUserUploads )).Methods ("DELETE" )
128
- r .Handle ("/qrcode" , stdChain .Then (handlers .GetQrCode )).Methods ("GET" )
129
- r .PathPrefix ("/clients/" ).Handler (http .StripPrefix ("/clients/" , http .FileServer (http .Dir ("../clients" ))))
130
- r .PathPrefix ("/changelog/" ).Handler (http .StripPrefix ("/changelog/" , http .FileServer (http .Dir ("../changelog" ))))
131
- r .PathPrefix ("/" ).Handler (http .FileServer (http .Dir ("./public/" )))
132
- http .Handle ("/" , r )
100
+ router := mux .NewRouter ()
101
+ router .Handle ("/config" , stdChain .Then (handlers .GetConfiguration )).Methods ("GET" )
102
+ router .Handle ("/version" , stdChain .Then (handlers .GetVersion )).Methods ("GET" )
103
+ router .Handle ("/upload" , tokenChain .Then (handlers .CreateUpload )).Methods ("POST" )
104
+ router .Handle ("/upload/{uploadID}" , authChain .Append (middleware .Upload ).Then (handlers .GetUpload )).Methods ("GET" )
105
+ router .Handle ("/upload/{uploadID}" , authChain .Append (middleware .Upload ).Then (handlers .RemoveUpload )).Methods ("DELETE" )
106
+ router .Handle ("/file/{uploadID}" , tokenChain .Append (middleware .Upload ).Then (handlers .AddFile )).Methods ("POST" )
107
+ router .Handle ("/file/{uploadID}/{fileID}/{filename}" , tokenChain .Append (middleware .Upload , middleware .File ).Then (handlers .AddFile )).Methods ("POST" )
108
+ router .Handle ("/file/{uploadID}/{fileID}/{filename}" , authChain .Append (middleware .Upload , middleware .File ).Then (handlers .RemoveFile )).Methods ("DELETE" )
109
+ router .Handle ("/file/{uploadID}/{fileID}/{filename}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
110
+ router .Handle ("/file/{uploadID}/{fileID}/{filename}/yubikey/{yubikey}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
111
+ router .Handle ("/stream/{uploadID}/{fileID}/{filename}" , tokenChain .Append (middleware .Upload , middleware .File ).Then (handlers .AddFile )).Methods ("POST" )
112
+ router .Handle ("/stream/{uploadID}/{fileID}/{filename}" , authChain .Append (middleware .Upload , middleware .File ).Then (handlers .RemoveFile )).Methods ("DELETE" )
113
+ router .Handle ("/stream/{uploadID}/{fileID}/{filename}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
114
+ router .Handle ("/stream/{uploadID}/{fileID}/{filename}/yubikey/{yubikey}" , authChainWithRedirect .AppendChain (getFileChain ).Then (handlers .GetFile )).Methods ("HEAD" , "GET" )
115
+ router .Handle ("/archive/{uploadID}/{filename}" , authChainWithRedirect .Append (middleware .Upload , middleware .Yubikey ).Then (handlers .GetArchive )).Methods ("HEAD" , "GET" )
116
+ router .Handle ("/archive/{uploadID}/{filename}/yubikey/{yubikey}" , authChainWithRedirect .Append (middleware .Upload , middleware .Yubikey ).Then (handlers .GetArchive )).Methods ("HEAD" , "GET" )
117
+ router .Handle ("/auth/google/login" , authChain .Then (handlers .GoogleLogin )).Methods ("GET" )
118
+ router .Handle ("/auth/google/callback" , stdChainWithRedirect .Then (handlers .GoogleCallback )).Methods ("GET" )
119
+ router .Handle ("/auth/ovh/login" , authChain .Then (handlers .OvhLogin )).Methods ("GET" )
120
+ router .Handle ("/auth/ovh/callback" , stdChainWithRedirect .Then (handlers .OvhCallback )).Methods ("GET" )
121
+ router .Handle ("/auth/logout" , authChain .Then (handlers .Logout )).Methods ("GET" )
122
+ router .Handle ("/me" , authChain .Then (handlers .UserInfo )).Methods ("GET" )
123
+ router .Handle ("/me" , authChain .Then (handlers .DeleteAccount )).Methods ("DELETE" )
124
+ router .Handle ("/me/token" , authChain .Then (handlers .CreateToken )).Methods ("POST" )
125
+ router .Handle ("/me/token/{token}" , authChain .Then (handlers .RevokeToken )).Methods ("DELETE" )
126
+ router .Handle ("/me/uploads" , authChain .Then (handlers .GetUserUploads )).Methods ("GET" )
127
+ router .Handle ("/me/uploads" , authChain .Then (handlers .RemoveUserUploads )).Methods ("DELETE" )
128
+ router .Handle ("/qrcode" , stdChain .Then (handlers .GetQrCode )).Methods ("GET" )
129
+ router .PathPrefix ("/clients/" ).Handler (http .StripPrefix ("/clients/" , http .FileServer (http .Dir ("../clients" ))))
130
+ router .PathPrefix ("/changelog/" ).Handler (http .StripPrefix ("/changelog/" , http .FileServer (http .Dir ("../changelog" ))))
131
+ router .PathPrefix ("/" ).Handler (http .FileServer (http .Dir ("./public/" )))
132
+
133
+ handler := common .StripPrefix (common .Config .Path , router )
134
+
135
+ http .Handle ("/" , handler )
133
136
134
137
go UploadsCleaningRoutine ()
135
138
@@ -150,10 +153,10 @@ func main() {
150
153
}
151
154
152
155
tlsConfig := & tls.Config {MinVersion : tls .VersionTLS10 , Certificates : []tls.Certificate {cert }}
153
- server = & http.Server {Addr : address , Handler : r , TLSConfig : tlsConfig }
156
+ server = & http.Server {Addr : address , Handler : handler , TLSConfig : tlsConfig }
154
157
} else {
155
158
proto = "http"
156
- server = & http.Server {Addr : address , Handler : r }
159
+ server = & http.Server {Addr : address , Handler : handler }
157
160
}
158
161
159
162
log .Infof ("Starting http server at %s://%s" , proto , address )
0 commit comments