mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2024-12-21 02:03:19 +00:00
24f6a447f3
Bumps [github.com/jackc/pgx/v4](https://github.com/jackc/pgx) from 4.17.2 to 4.18.1. - [Release notes](https://github.com/jackc/pgx/releases) - [Changelog](https://github.com/jackc/pgx/blob/v4.18.1/CHANGELOG.md) - [Commits](https://github.com/jackc/pgx/compare/v4.17.2...v4.18.1) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package pgproto3
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/jackc/pgio"
|
|
)
|
|
|
|
type SASLResponse struct {
|
|
Data []byte
|
|
}
|
|
|
|
// Frontend identifies this message as sendable by a PostgreSQL frontend.
|
|
func (*SASLResponse) Frontend() {}
|
|
|
|
// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
|
|
// type identifier and 4 byte message length.
|
|
func (dst *SASLResponse) Decode(src []byte) error {
|
|
*dst = SASLResponse{Data: src}
|
|
return nil
|
|
}
|
|
|
|
// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
|
|
func (src *SASLResponse) Encode(dst []byte) []byte {
|
|
dst = append(dst, 'p')
|
|
dst = pgio.AppendInt32(dst, int32(4+len(src.Data)))
|
|
|
|
dst = append(dst, src.Data...)
|
|
|
|
return dst
|
|
}
|
|
|
|
// MarshalJSON implements encoding/json.Marshaler.
|
|
func (src SASLResponse) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(struct {
|
|
Type string
|
|
Data string
|
|
}{
|
|
Type: "SASLResponse",
|
|
Data: string(src.Data),
|
|
})
|
|
}
|
|
|
|
// UnmarshalJSON implements encoding/json.Unmarshaler.
|
|
func (dst *SASLResponse) UnmarshalJSON(data []byte) error {
|
|
var msg struct {
|
|
Data string
|
|
}
|
|
if err := json.Unmarshal(data, &msg); err != nil {
|
|
return err
|
|
}
|
|
dst.Data = []byte(msg.Data)
|
|
return nil
|
|
}
|