summaryrefslogtreecommitdiff
path: root/system/addon/api.go
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2017-01-16 16:14:00 -0800
committerGitHub <noreply@github.com>2017-01-16 16:14:00 -0800
commit2af951230eddc45ba429cff10d7566ad98fd343b (patch)
tree7543be03fae8aeeacc8eb48dbe16ab2d42fbca0b /system/addon/api.go
parent3249b82b2a4f1aa0ae9e6943cd72dd7eebae8a4a (diff)
[core] Adding toggle for CORS, GZIP in admin/cms configuration (#30)
This PR enables admins to disable/enable CORS and GZIP from within the admin CMS configuration page. Both are enabled by default. Note: currently, the GZIP implementation is 100% on the fly, for every qualifying API endpoint request. This could add significant CPU usage, but dramatically decreases bandwidth. Will be considering other better implementations, but for now YMMV. Possible optimizations: - pooling gzip Writers vs. creating a new one for each response - caching gzipped responses (in memory? on disk?) - enforcing size threshold (only gzip content larger than N bytes)
Diffstat (limited to 'system/addon/api.go')
-rw-r--r--system/addon/api.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/system/addon/api.go b/system/addon/api.go
index 9b54d6e..cd792aa 100644
--- a/system/addon/api.go
+++ b/system/addon/api.go
@@ -18,8 +18,8 @@ type QueryOptions db.QueryOptions
// ContentAll retrives all items from the HTTP API within the provided namespace
func ContentAll(namespace string) []byte {
- host := db.ConfigCache("domain")
- port := db.ConfigCache("http_port")
+ host := db.ConfigCache("domain").(string)
+ port := db.ConfigCache("http_port").(string)
endpoint := "http://%s:%s/api/contents?type=%s&count=-1"
URL := fmt.Sprintf(endpoint, host, port, namespace)
@@ -35,8 +35,8 @@ func ContentAll(namespace string) []byte {
// Query retrieves a set of content from the HTTP API based on options
// and returns the total number of content in the namespace and the content
func Query(namespace string, opts QueryOptions) []byte {
- host := db.ConfigCache("domain")
- port := db.ConfigCache("http_port")
+ host := db.ConfigCache("domain").(string)
+ port := db.ConfigCache("http_port").(string)
endpoint := "http://%s:%s/api/contents?type=%s&count=%d&offset=%d&order=%s"
URL := fmt.Sprintf(endpoint, host, port, namespace, opts.Count, opts.Offset, opts.Order)