mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-04 12:27:44 +00:00
Add Nextcloud Talk support (#1167)
Signed-off-by: Gary Kim <gary@garykim.dev>
This commit is contained in:
20
vendor/github.com/monaco-io/request/.gitignore
generated
vendored
Normal file
20
vendor/github.com/monaco-io/request/.gitignore
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
coverage.txt
|
16
vendor/github.com/monaco-io/request/.travis.yml
generated
vendored
Normal file
16
vendor/github.com/monaco-io/request/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.14.x
|
||||
- tip
|
||||
|
||||
sudo: false
|
||||
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
|
||||
script:
|
||||
- go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash) -t 6cf6f7ab-26e6-429c-ac44-f0ad85c1e586
|
76
vendor/github.com/monaco-io/request/CODE_OF_CONDUCT.md
generated
vendored
Normal file
76
vendor/github.com/monaco-io/request/CODE_OF_CONDUCT.md
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at luxuze@agora.io. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
<https://www.contributor-covenant.org/faq>
|
1
vendor/github.com/monaco-io/request/CONTRIBUTING.md
generated
vendored
Normal file
1
vendor/github.com/monaco-io/request/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
# CONTRIBUTING
|
21
vendor/github.com/monaco-io/request/LICENSE
generated
vendored
Normal file
21
vendor/github.com/monaco-io/request/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Monaco.HappyHacking
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
197
vendor/github.com/monaco-io/request/README.md
generated
vendored
Normal file
197
vendor/github.com/monaco-io/request/README.md
generated
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
# Request [](https://github.com/avelino/awesome-go) [](https://goreportcard.com/report/github.com/monaco-io/request) 
|
||||
|
||||
<img align="right" width="159px" src="https://raw.githubusercontent.com/gin-gonic/logo/master/color.png">
|
||||
|
||||
[](https://travis-ci.org/monaco-io/request)
|
||||
[](https://pkg.go.dev/github.com/monaco-io/request?tab=doc)
|
||||
[](https://codecov.io/gh/monaco-io/request)
|
||||
[](https://github.com/monaco-io/request/releases)
|
||||
[](https://www.tickgit.com/browse?repo=github.com/monaco-io/request)
|
||||
[](https://github.com/monaco-io/request/blob/master/LICENSE)
|
||||
<!-- [](https://sourcegraph.com/github.com/monaco-io/request?badge) -->
|
||||
<!-- [](https://www.codetriage.com/monaco-io/request) -->
|
||||
<!-- [](https://gitter.im/monaco-io/request?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -->
|
||||
|
||||
HTTP client for golang, Inspired by [Javascript-axios](https://github.com/axios/axios) [Python-request](https://github.com/psf/requests).
|
||||
If you have experience about axios or requests, you will love it.
|
||||
No 3rd dependency.
|
||||
|
||||
## Features
|
||||
|
||||
- Make [http](https://golang.org) requests from Golang
|
||||
- Intercept request and response
|
||||
- Transform request and response data
|
||||
|
||||
## Installing
|
||||
|
||||
go mod:
|
||||
|
||||
```bash
|
||||
go get github.com/monaco-io/request
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
- OPTIONS
|
||||
- GET
|
||||
- HEAD
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
- TRACE
|
||||
- CONNECT
|
||||
|
||||
## Example
|
||||
|
||||
### GET
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/monaco-io/request"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := request.Client{
|
||||
URL: "https://google.com",
|
||||
Method: "GET",
|
||||
Params: map[string]string{"hello": "world"},
|
||||
}
|
||||
resp, err := client.Do()
|
||||
|
||||
log.Println(resp.Code, string(resp.Data), err)
|
||||
}
|
||||
```
|
||||
|
||||
### POST
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/monaco-io/request"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := request.Client{
|
||||
URL: "https://google.com",
|
||||
Method: "POST",
|
||||
Params: map[string]string{"hello": "world"},
|
||||
Body: []byte(`{"hello": "world"}`),
|
||||
}
|
||||
resp, err := client.Do()
|
||||
|
||||
log.Println(resp.Code, string(resp.Data), err)
|
||||
}
|
||||
```
|
||||
|
||||
### Content-Type
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/monaco-io/request"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := request.Client{
|
||||
URL: "https://google.com",
|
||||
Method: "POST",
|
||||
ContentType: request.ApplicationXWwwFormURLEncoded, // default is "application/json"
|
||||
}
|
||||
resp, err := client.Do()
|
||||
|
||||
log.Println(resp.Code, string(resp.Data), err)
|
||||
}
|
||||
```
|
||||
|
||||
### Authorization
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/monaco-io/request"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := request.Client{
|
||||
URL: "https://google.com",
|
||||
Method: "POST",
|
||||
BasicAuth: request.BasicAuth{
|
||||
Username:"user_xxx",
|
||||
Password:"pwd_xxx",
|
||||
}, // xxx:xxx
|
||||
}
|
||||
|
||||
resp, err := client.Do()
|
||||
|
||||
log.Println(resp.Code, string(resp.Data), err)
|
||||
}
|
||||
```
|
||||
|
||||
### Timeout
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/monaco-io/request"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := request.Client{
|
||||
URL: "https://google.com",
|
||||
Method: "POST",
|
||||
Timeout: 10, // seconds
|
||||
}
|
||||
|
||||
resp, err := client.Do()
|
||||
|
||||
log.Println(resp.Code, string(resp.Data), err)
|
||||
}
|
||||
```
|
||||
|
||||
### Cookies
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/monaco-io/request"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := request.Client{
|
||||
URL: "https://google.com",
|
||||
Cookies:[]*http.Cookie{
|
||||
{
|
||||
Name: "cookie_name",
|
||||
Value: "cookie_value",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := client.Do()
|
||||
|
||||
log.Println(resp.Code, string(resp.Data), err)
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
59
vendor/github.com/monaco-io/request/doc.go
generated
vendored
Normal file
59
vendor/github.com/monaco-io/request/doc.go
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
// Package request HTTP client for golang
|
||||
// - Make http requests from Golang
|
||||
// - Intercept request and response
|
||||
// - Transform request and response data
|
||||
//
|
||||
// GET
|
||||
//
|
||||
// client := request.Client{
|
||||
// URL: "https://google.com",
|
||||
// Method: "GET",
|
||||
// Params: map[string]string{"hello": "world"},
|
||||
// }
|
||||
// resp, err := client.Do()
|
||||
//
|
||||
// POST
|
||||
//
|
||||
// client := request.Client{
|
||||
// URL: "https://google.com",
|
||||
// Method: "POST",
|
||||
// Params: map[string]string{"hello": "world"},
|
||||
// Body: []byte(`{"hello": "world"}`),
|
||||
// }
|
||||
// resp, err := client.Do()
|
||||
//
|
||||
// Content-Type
|
||||
//
|
||||
// client := request.Client{
|
||||
// URL: "https://google.com",
|
||||
// Method: "POST",
|
||||
// ContentType: request.ApplicationXWwwFormURLEncoded, // default is "application/json"
|
||||
// }
|
||||
// resp, err := client.Do()
|
||||
//
|
||||
// Authorization
|
||||
//
|
||||
// client := request.Client{
|
||||
// URL: "https://google.com",
|
||||
// Method: "POST",
|
||||
// BasicAuth: request.BasicAuth{
|
||||
// Username:"user_xxx",
|
||||
// Password:"pwd_xxx",
|
||||
// }, // xxx:xxx
|
||||
// }
|
||||
//
|
||||
// resp, err := client.Do()
|
||||
//
|
||||
// Cookies
|
||||
// client := request.Client{
|
||||
// URL: "https://google.com",
|
||||
// Cookies:[]*http.Cookie{
|
||||
// {
|
||||
// Name: "cookie_name",
|
||||
// Value: "cookie_value",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// resp, err := client.Do()
|
||||
package request
|
3
vendor/github.com/monaco-io/request/go.mod
generated
vendored
Normal file
3
vendor/github.com/monaco-io/request/go.mod
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module github.com/monaco-io/request
|
||||
|
||||
go 1.14
|
0
vendor/github.com/monaco-io/request/go.sum
generated
vendored
Normal file
0
vendor/github.com/monaco-io/request/go.sum
generated
vendored
Normal file
66
vendor/github.com/monaco-io/request/model.go
generated
vendored
Normal file
66
vendor/github.com/monaco-io/request/model.go
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// ApplicationJSON application/json
|
||||
ApplicationJSON ContentType = "application/json"
|
||||
|
||||
// ApplicationXWwwFormURLEncoded application/x-www-form-urlencoded
|
||||
ApplicationXWwwFormURLEncoded ContentType = "application/x-www-form-urlencoded"
|
||||
|
||||
// MultipartFormData multipart/form-data
|
||||
MultipartFormData ContentType = "multipart/form-data"
|
||||
)
|
||||
|
||||
// ContentType Content-Type
|
||||
type ContentType string
|
||||
|
||||
// Client Method
|
||||
/*
|
||||
Method = "OPTIONS" ; Section 9.2
|
||||
| "GET" ; Section 9.3
|
||||
| "HEAD" ; Section 9.4
|
||||
| "POST" ; Section 9.5
|
||||
| "PUT" ; Section 9.6
|
||||
| "DELETE" ; Section 9.7
|
||||
| "TRACE" ; Section 9.8
|
||||
| "CONNECT" ; Section 9.9
|
||||
| extension-method
|
||||
extension-method = token
|
||||
token = 1*<any CHAR except CTLs or separators>
|
||||
*/
|
||||
type Client struct {
|
||||
URL string
|
||||
Method string
|
||||
Header map[string]string
|
||||
Params map[string]string
|
||||
Body []byte
|
||||
BasicAuth BasicAuth
|
||||
Timeout time.Duration // second
|
||||
ProxyURL string
|
||||
ContentType ContentType
|
||||
Cookies []*http.Cookie
|
||||
|
||||
// private
|
||||
client *http.Client
|
||||
req *http.Request
|
||||
}
|
||||
|
||||
// BasicAuth Add Username:Password as Basic Auth
|
||||
type BasicAuth struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
// SugaredResp Sugared response with status code and body data
|
||||
type SugaredResp struct {
|
||||
Data []byte
|
||||
Code int
|
||||
|
||||
// private
|
||||
resp *http.Response
|
||||
}
|
98
vendor/github.com/monaco-io/request/request.go
generated
vendored
Normal file
98
vendor/github.com/monaco-io/request/request.go
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Do send http request
|
||||
func (c *Client) Do() (resp SugaredResp, err error) {
|
||||
defer resp.Close()
|
||||
|
||||
if err := c.buildRequest(); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// send request and close on func call end
|
||||
if resp.resp, err = c.client.Do(c.req); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// read response data form resp
|
||||
resp.Data, err = ioutil.ReadAll(resp.resp.Body)
|
||||
resp.Code = resp.resp.StatusCode
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *Client) buildRequest() (err error) {
|
||||
|
||||
// encode requestURL.httpURL like https://google.com?hello=world&package=request
|
||||
ru := requestURL{
|
||||
urlString: c.URL,
|
||||
parameters: c.Params,
|
||||
}
|
||||
if err := ru.EncodeURL(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// build request
|
||||
c.req, err = http.NewRequest(c.Method, ru.string(), bytes.NewReader(c.Body))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// apply Header to request
|
||||
if c.Method == "POST" {
|
||||
if c.ContentType == "" {
|
||||
c.ContentType = ApplicationJSON
|
||||
}
|
||||
c.req.Header.Set("Content-Type", string(c.ContentType))
|
||||
}
|
||||
for k, v := range c.Header {
|
||||
c.req.Header.Add(k, v)
|
||||
}
|
||||
|
||||
// apply basic Auth of request header
|
||||
if c.BasicAuth.Username != "" && c.BasicAuth.Password != "" {
|
||||
c.req.SetBasicAuth(c.BasicAuth.Username, c.BasicAuth.Password)
|
||||
}
|
||||
|
||||
c.client = &http.Client{}
|
||||
|
||||
// apply timeout
|
||||
if c.Timeout > 0 {
|
||||
c.client.Timeout = c.Timeout * time.Second
|
||||
}
|
||||
|
||||
// apply cookies
|
||||
if c.Cookies != nil {
|
||||
jar, _ := cookiejar.New(nil)
|
||||
jar.SetCookies(&url.URL{Scheme: ru.scheme(), Host: ru.host()}, c.Cookies)
|
||||
c.client.Jar = jar
|
||||
}
|
||||
|
||||
// apply proxy
|
||||
if c.ProxyURL != "" {
|
||||
if proxy, err := url.Parse(c.ProxyURL); err == nil && proxy != nil {
|
||||
c.client.Transport = &http.Transport{
|
||||
Proxy: http.ProxyURL(proxy),
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Resp do request and get original http response struct
|
||||
func (c *Client) Resp() (resp *http.Response, err error) {
|
||||
if err = c.buildRequest(); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return c.client.Do(c.req)
|
||||
}
|
18
vendor/github.com/monaco-io/request/resp.go
generated
vendored
Normal file
18
vendor/github.com/monaco-io/request/resp.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
package request
|
||||
|
||||
// StatusCode get response status code
|
||||
func (s *SugaredResp) StatusCode() (code int) {
|
||||
return s.resp.StatusCode
|
||||
}
|
||||
|
||||
// Status get response status code and text, like 200 ok
|
||||
func (s *SugaredResp) Status() (status string) {
|
||||
return s.resp.Status
|
||||
}
|
||||
|
||||
// Close close response body
|
||||
func (s *SugaredResp) Close() {
|
||||
if s.resp != nil {
|
||||
_ = s.resp.Body.Close()
|
||||
}
|
||||
}
|
36
vendor/github.com/monaco-io/request/url.go
generated
vendored
Normal file
36
vendor/github.com/monaco-io/request/url.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
package request
|
||||
|
||||
import "net/url"
|
||||
|
||||
type requestURL struct {
|
||||
httpURL *url.URL
|
||||
urlString string
|
||||
parameters map[string]string
|
||||
}
|
||||
|
||||
// EncodeURL add and encoded parameters.
|
||||
func (ru *requestURL) EncodeURL() (err error) {
|
||||
ru.httpURL, err = url.Parse(ru.urlString)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
query := ru.httpURL.Query()
|
||||
for k := range ru.parameters {
|
||||
query.Set(k, ru.parameters[k])
|
||||
}
|
||||
ru.httpURL.RawQuery = query.Encode()
|
||||
return err
|
||||
}
|
||||
|
||||
// String return example: https://www.google.com/search?a=1&b=2
|
||||
func (ru requestURL) string() string {
|
||||
return ru.httpURL.String()
|
||||
}
|
||||
|
||||
func (ru requestURL) scheme() string {
|
||||
return ru.httpURL.Scheme
|
||||
}
|
||||
|
||||
func (ru requestURL) host() string {
|
||||
return ru.httpURL.Host
|
||||
}
|
Reference in New Issue
Block a user