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.

34 lines
691 B
Go

package bugbox
import (
"fmt"
"net/http"
"strings"
)
2 months ago
// EnclosureStore describes an interface to managing Enclosures
type EnclosureStore interface {
// Retrieves an enclosure by name
GetEnclosure(name string) string
}
2 months ago
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/")
2 months ago
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
}