Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10669558
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/writeas.go b/writeas.go
index fc8d028..7255067 100644
--- a/writeas.go
+++ b/writeas.go
@@ -1,48 +1,48 @@
package writeas
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"time"
)
const (
- apiURL = "http://i.write.as"
+ apiURL = "https://write.as/api"
)
type API struct {
BaseURL string
}
// defaultHTTPTimeout is the default http.Client timeout.
const defaultHTTPTimeout = 10 * time.Second
var httpClient = &http.Client{Timeout: defaultHTTPTimeout}
func GetAPI() *API {
return &API{apiURL}
}
func (a API) Call(method, path string) (int, string, error) {
if method != "GET" && method != "HEAD" {
return 0, "", errors.New(fmt.Sprintf("Method %s not currently supported by library (only HEAD and GET).\n", method))
}
r, _ := http.NewRequest(method, fmt.Sprintf("%s%s", a.BaseURL, path), nil)
r.Header.Add("User-Agent", "writeas-go v1")
resp, err := httpClient.Do(r)
if err != nil {
return 0, "", err
}
defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return resp.StatusCode, "", err
}
return resp.StatusCode, string(content), nil
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, May 16, 11:28 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3240086
Attached To
rWGO writeas-go
Event Timeline
Log In to Comment