You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package bugbox
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EnclosureStore describes an interface to managing Enclosures
|
|
|
|
type EnclosureStore interface {
|
|
|
|
// Retrieves an enclosure by name
|
|
|
|
GetEnclosure(name string) string
|
|
|
|
}
|
|
|
|
|
|
|
|
type BugBoxServer struct {
|
|
|
|
EnclosureStore EnclosureStore
|
|
|
|
}
|
|
|
|
|
|
|
|
// This implements the Handler interface
|
|
|
|
func (b *BugBoxServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
enclosure := strings.TrimPrefix(r.URL.Path, "/enclosure/")
|
|
|
|
e := b.EnclosureStore.GetEnclosure(enclosure)
|
|
|
|
if e == "" {
|
|
|
|
w.WriteHeader(http.StatusNotFound)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Fprint(w, e)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetEnclosure retrieves the requested enclosure
|
|
|
|
func GetEnclosure(name string) string {
|
|
|
|
return name
|
|
|
|
}
|