ErrBadRequest=errors.New("lenpaste: bad request")// HTTP code 400; This API method exists on the server, but you passed the wrong arguments for it.
ErrNotFoundID =errors.New("lenpaste: could not find ID")// HTTP code 404; There is no paste with this ID.
ErrNotFound=errors.New("lenpaste: not found")// HTTP code 404; There is no such API method.
ErrMethodNotAllowed =errors.New("lenpaste: method not allowed")// HTTP code 405; You made a mistake with HTTP request (example: you made POST instead of GET).
ErrInternalServerError =errors.New("lenpaste: internal server error")// HTTP code 500; There was a failure on the server.
ErrUnknown =errors.New("lenpaste: unknown")// Other HTTP code not equal to 200.
ErrBadRequest=errors.New("lenpaste: 400 bad request")// HTTP code 400; This API method exists on the server, but you passed the wrong arguments for it.
ErrUnauthorized =errors.New("lenpaste: 401 unauthorized")// HTTP code 401; This server requires authentication.
ErrNotFoundID=errors.New("lenpaste: 404 could not find ID")// HTTP code 404; There is no paste with this ID.
ErrNotFound =errors.New("lenpaste: 404 not found")// HTTP code 404; There is no such API method.
ErrMethodNotAllowed =errors.New("lenpaste: 405 method not allowed")// HTTP code 405; You made a mistake with HTTP request (example: you made POST instead of GET).
ErrInternalServerError =errors.New("lenpaste: 500 internal server error")// HTTP code 500; There was a failure on the server.
)
const(
@ -30,6 +31,10 @@ type Server struct {
// Example: https://paste.lcomrade.su
// Warning: If you add / to the end of the address, it will cause an error!
Serverstring
// If the user or password is blank, no authorization will be performed.
AuthUserstring
AuthPassstring
}
typeerrorAnswerstruct{
@ -44,7 +49,7 @@ type NewPaste struct {
Syntaxstring// Web interface syntax highlighting (default: plaintext).
OneUsebool// If set to "true", the paste can be viewed once (default: false).
Expirationint64// The time in seconds that the paste will live (default: unlimited).
Authorstring// Author name (may not be set).
Authorstring// Author name (may not be set).
AuthorEmailstring// Author email (may not be set).
AuthorURLstring// Author URL (may not be set).
}
@ -57,21 +62,24 @@ type Paste struct {
DeleteTimeint64`json:"deleteTime"`// The time after which the paste will be removed. If set to "0", the paste has no expiration date.
OneUsebool`json:"oneUse"`// If set to "true", the paste can be viewed once.
Syntaxstring`json:"syntax"`// Web interface syntax highlighting. If set to "plaintext", syntax highlighting is disabled.
Authorstring`json:"author"`// Author name (can be blank).
Authorstring`json:"author"`// Author name (can be blank).
AuthorEmailstring`json:"authorEmail"`// Author email (can be blank).
AuthorURLstring`json:"authorURL"`// Author URL (can be blank).
}
typeServerInfostruct{
Versionstring`json:"version"`// Version of Lenpaste installed on server.
TitleMaxLenint`json:"titleMaxlength"`// Maximum length paste title can have. If 0 disable title, if -1 disable length limit.
BodyMaxLenint`json:"bodyMaxlength"`// Maximum length paste body can have. If -1 disable length limit. Can't be -1.
MaxLifeTimeint64`json:"maxLifeTime"`// Maximum "Expiration" value.
ServerAboutstring`json:"serverAbout"`// Server description (can be blank).
ServerRulesstring`json:"serverRules"`// Server rules (can be blank).
AdminNamestring`json:"adminName"`// Server administrator name (can be blank).
AdminMailstring`json:"adminMail"`// Server administrator email (can be blank).
Syntaxes[]string`json:"syntaxes"`// Syntaxes that this server can highlight in the web interface. For example: "plaintext", "Go", "C", and so on.
Versionstring`json:"version"`// Version of Lenpaste installed on server.
TitleMaxLenint`json:"titleMaxlength"`// Maximum length paste title can have. If 0 disable title, if -1 disable length limit.
BodyMaxLenint`json:"bodyMaxlength"`// Maximum length paste body can have. If -1 disable length limit. Can't be -1.
MaxLifeTimeint64`json:"maxLifeTime"`// Maximum "Expiration" value.
ServerAboutstring`json:"serverAbout"`// Server description (can be blank).
ServerRulesstring`json:"serverRules"`// Server rules (can be blank).
ServerTermsOfUsestring`json:"serverTermsOfUse"`// Server Terms of Use (can be blank).
AdminNamestring`json:"adminName"`// Server administrator name (can be blank).
AdminMailstring`json:"adminMail"`// Server administrator email (can be blank).
Syntaxes[]string`json:"syntaxes"`// Syntaxes that this server can highlight in the web interface. For example: "plaintext", "Go", "C", and so on.
UiDefaultLifeTimestring`json:"uiDefaultLifeTime"`// Default lifetime of paste selected in UI. Possible values: 10min, 1h, 1d, 2w, 6mon, 1y.
AuthRequiredbool`json:"authRequired"`// If true, authorization is required to create paste.
}
// NewServer is intended to replace the manual filling of fields in the Server structure.
@ -82,6 +90,15 @@ func NewServer(address string) Server {
}
}
// Auth remembers the user and password for authorization on the server requesting it.
//
// The correctness of the data entered is not checked.
// If the user or password is blank, no authorization will be performed.