|
@@ -4,24 +4,24 @@ import (
|
|
|
"net/http"
|
|
|
)
|
|
|
|
|
|
-type Resource struct {
|
|
|
+type OneResource struct {
|
|
|
Path string
|
|
|
Ctype string
|
|
|
Bytes []byte
|
|
|
}
|
|
|
|
|
|
-type resource struct {
|
|
|
+type Resource struct {
|
|
|
maxurl int
|
|
|
- list map[string]Resource
|
|
|
+ list map[string]OneResource
|
|
|
}
|
|
|
|
|
|
-func New() *resource {
|
|
|
- r := resource{maxurl: 0}
|
|
|
- r.list = map[string]Resource{}
|
|
|
+func New() *Resource {
|
|
|
+ r := Resource{maxurl: 0}
|
|
|
+ r.list = map[string]OneResource{}
|
|
|
return &r
|
|
|
}
|
|
|
|
|
|
-func (this *resource) Add(path string, ctype string, bytes []byte) {
|
|
|
+func (this *Resource) Add(path string, ctype string, bytes []byte) {
|
|
|
// Do not add if already in resources list
|
|
|
if _, ok := this.list[path]; ok == true {
|
|
|
return
|
|
@@ -29,14 +29,14 @@ func (this *resource) Add(path string, ctype string, bytes []byte) {
|
|
|
|
|
|
// Add to resources list
|
|
|
this.maxurl = len(path)
|
|
|
- this.list[path] = Resource{
|
|
|
+ this.list[path] = OneResource{
|
|
|
Path: path,
|
|
|
Ctype: ctype,
|
|
|
Bytes: bytes,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (this *resource) Response(w http.ResponseWriter, r *http.Request, before func(w http.ResponseWriter, r *http.Request, i *Resource), after func(w http.ResponseWriter, r *http.Request, i *Resource)) bool {
|
|
|
+func (this *Resource) Response(w http.ResponseWriter, r *http.Request, before func(w http.ResponseWriter, r *http.Request, i *OneResource), after func(w http.ResponseWriter, r *http.Request, i *OneResource)) bool {
|
|
|
// Do not process if this is not necessary
|
|
|
if len(r.URL.Path) <= 1 || len(r.URL.Path)-1 > this.maxurl {
|
|
|
return false
|