Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download api/pkg/discord/response.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 731 Bytes
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/discord/response.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/api/pkg/discord/response.go
-
curl -L -o response.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/discord/response.go
731 Bytes
| package discord | |
| import ( | |
| "bytes" | |
| "errors" | |
| "net/http" | |
| "strconv" | |
| ) | |
| // Response captures the http response | |
| type Response struct { | |
| HTTPResponse *http.Response | |
| Body *[]byte | |
| } | |
| // Error ensures that the response can be decoded into a string inc ase it's an error response | |
| func (r *Response) Error() error { | |
| switch r.HTTPResponse.StatusCode { | |
| case 200, 201, 202, 204, 205: | |
| return nil | |
| default: | |
| return errors.New(r.errorMessage()) | |
| } | |
| } | |
| func (r *Response) errorMessage() string { | |
| var buf bytes.Buffer | |
| buf.WriteString(strconv.Itoa(r.HTTPResponse.StatusCode)) | |
| buf.WriteString(": ") | |
| buf.WriteString(http.StatusText(r.HTTPResponse.StatusCode)) | |
| buf.WriteString(", Body: ") | |
| buf.Write(*r.Body) | |
| return buf.String() | |
| } | |