mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
made backend varaible public (#104)
This commit is contained in:
committed by
GitHub
parent
9775525d35
commit
1766aa85cb
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
type WebapiInstance struct {
|
||||
backend *core.Backend
|
||||
Backend *core.Backend
|
||||
geoipCityReader *geoip2.CityReader
|
||||
|
||||
// Router can be used to register additional API functions
|
||||
@@ -57,7 +57,7 @@ func Start(Backend *core.Backend, ListenAddresses []string, UseSSL bool, Certifi
|
||||
}
|
||||
|
||||
api = &WebapiInstance{
|
||||
backend: Backend,
|
||||
Backend: Backend,
|
||||
Router: mux.NewRouter(),
|
||||
AllowKeyInParam: []string{"/file/read", "/file/view"},
|
||||
allJobs: make(map[uuid.UUID]*SearchJob),
|
||||
@@ -170,7 +170,7 @@ func DecodeJSON(w http.ResponseWriter, r *http.Request, data interface{}) (err e
|
||||
|
||||
// authenticateMiddleware returns a middleware function to be used with mux.Router.Use(). It handles all authentication functionality.
|
||||
func (api *WebapiInstance) authenticateMiddleware(APIKey uuid.UUID) func(http.Handler) http.Handler {
|
||||
return (func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
keyID, err := uuid.Parse(r.Header.Get("x-api-key"))
|
||||
if err != nil { // special case for some paths
|
||||
@@ -194,5 +194,5 @@ func (api *WebapiInstance) authenticateMiddleware(APIKey uuid.UUID) func(http.Ha
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user