-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17363fc
commit 6738ce8
Showing
10 changed files
with
231 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package api | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/fabiolb/fabio/registry" | ||
) | ||
|
||
type ManualPathsHandler struct { | ||
Prefix string | ||
} | ||
|
||
func (h *ManualPathsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
// we need this for testing. | ||
// under normal circumstances this is never nil | ||
if registry.Default == nil { | ||
return | ||
} | ||
|
||
switch r.Method { | ||
case "GET": | ||
paths, err := registry.Default.ManualPaths() | ||
if err != nil { | ||
log.Print("[ERROR] ", err) | ||
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
for i, p := range paths { | ||
paths[i] = strings.TrimPrefix(p, h.Prefix) | ||
} | ||
writeJSON(w, r, paths) | ||
return | ||
|
||
default: | ||
http.Error(w, "not allowed", http.StatusMethodNotAllowed) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.