Documentation
¶
Index ¶
- Variables
- func GenerateID(t string, l int) string
- func GenerateKey(length int) string
- func GeneratePhrase(length int) string
- func Highlight(code string, extension string) (string, string, error)
- func Logger(next http.Handler) http.Handler
- func ParseRatelimiterString(rl string) (int, time.Duration, error)
- func RenderError(r *embed.FS, w http.ResponseWriter, status int, err error) error
- func ValidateBody(maxSize int, body CreateRequest) error
- func WriteError(w http.ResponseWriter, status int, e error) error
- func WriteJSON[R any](w http.ResponseWriter, status int, r R) error
- type CreateRequest
- type DocumentResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTooManyParts = errors.New("ratelimiter string invalid: too many parts")
Functions ¶
func GenerateID ¶
func GenerateKey ¶
func GeneratePhrase ¶
func RenderError ¶
RenderError renders errors to the client using an HTML template.
func ValidateBody ¶
func ValidateBody(maxSize int, body CreateRequest) error
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, e error) error
WriteError writes an Error object (e) to an HTTP response writer (w)
Types ¶
type CreateRequest ¶
type CreateRequest struct {
Content string
}
func HandleBody ¶
func HandleBody(maxSize int, r *http.Request) (CreateRequest, error)
HandleBody figures out whether a incoming request is in JSON or multipart/form-data and decodes it appropriately
type DocumentResponse ¶
type DocumentResponse struct { ID string `json:"id,omitempty"` // The document ID. Content string `json:"content,omitempty"` // The document content. CreatedAt int64 `json:"created_at,omitempty"` // The Unix timestamp of when the document was inserted. UpdatedAt int64 `json:"updated_at,omitempty"` // The Unix timestamp of when the document was last modified. Exists bool `json:"exists,omitempty"` // Whether the document does or does not exist. }
DocumentResponse is a document object
Click to show internal directories.
Click to hide internal directories.