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/requests/message_index_request.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/api/pkg/requests/message_index_request.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@6917738ca6db1603dee9e07994b4e42d5e1ae9b2/api/pkg/requests/message_index_request.go
-
curl -L -o message_index_request.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/api/pkg/requests/message_index_request.go
1.76 kB
| package requests | |
| import ( | |
| "strconv" | |
| "strings" | |
| "github.com/NdoleStudio/httpsms/pkg/entities" | |
| "github.com/NdoleStudio/httpsms/pkg/repositories" | |
| "github.com/NdoleStudio/httpsms/pkg/services" | |
| ) | |
| // MessageIndex is the payload fetching entities.Message sent between 2 numbers | |
| type MessageIndex struct { | |
| Skip string `json:"skip" query:"skip"` | |
| Contact string `json:"contact" query:"contact"` | |
| Owner string `json:"owner" query:"owner"` | |
| Query string `json:"query" query:"query"` | |
| Limit string `json:"limit" query:"limit"` | |
| } | |
| // Sanitize sets defaults to MessageOutstanding | |
| func (input *MessageIndex) Sanitize() MessageIndex { | |
| if strings.TrimSpace(input.Limit) == "" { | |
| input.Limit = "20" | |
| } | |
| input.Query = strings.TrimSpace(input.Query) | |
| input.Owner = input.sanitizeAddress(input.Owner) | |
| input.Contact = input.sanitizeAddress(input.Contact) | |
| input.Skip = strings.TrimSpace(input.Skip) | |
| if input.Skip == "" { | |
| input.Skip = "0" | |
| } | |
| return *input | |
| } | |
| // ToGetParams converts request to services.MessageGetParams | |
| func (input *MessageIndex) ToGetParams(userID entities.UserID) services.MessageGetParams { | |
| return services.MessageGetParams{ | |
| IndexParams: repositories.IndexParams{ | |
| Skip: input.getInt(input.Skip), | |
| Query: input.Query, | |
| Limit: input.getInt(input.Limit), | |
| }, | |
| UserID: userID, | |
| Owner: input.Owner, | |
| Contact: input.Contact, | |
| } | |
| } | |
| // getLimit gets the take as a string | |
| func (input *MessageIndex) sanitizeAddress(value string) string { | |
| value = strings.TrimRight(value, " ") | |
| if len(value) > 0 && value[0] == ' ' { | |
| value = strings.Replace(value, " ", "+", 1) | |
| } | |
| return value | |
| } | |
| // getLimit gets the take as a string | |
| func (input *MessageIndex) getInt(value string) int { | |
| val, _ := strconv.Atoi(value) | |
| return val | |
| } | |