package
0.0.0-20241113112105-d5176070b8d9
Repository: https://github.com/ortizdavid/go-nopain.git
Documentation: pkg.go.dev

# README

httputils

Package for http common needs

Featuares

  • Response customization (JSON and XML)
  • Response with HATEOAS
  • HTTP Authentication (Basic and API Key) middlewares
  • HTTP Client
  • Pagination JSON and XML

# Functions

Return a ApiKeyMiddleware object, and initialize default key with the apiKey passed.
NewApiKeyUserMiddleware creates a new instance of ApiKeyUserMiddleware with the provided list of user keys.
NewBasicAuthMiddleware returns a new BasicAuthMiddleware object with the provided username and password.
No description provided by the author
NewGorillaStore creates a new session store with a secret key.
NewHttpClient creates a new instance of HttpClient.
No description provided by the author
NewPaginationXML creates a Pagination object for XML response.
NewSessionGorilla creates a new session with custom settings.
NewSessionGorillaDefault creates a new session with default settings.
NewSessionHttp creates a new session with a custom cookie name and expiration.
NewSessionHttpDefault creates a new session with default settings.
No description provided by the author
No description provided by the author
WriteHateoasJson writes a HATEOAS JSON response with the provided status code, data, and count.
WriteJson writes a simple JSON response with the provided status code and data.
WriteJsonError writes a JSON error response with the provided message and status code.
WriteJsonPaginated writes a paginated JSON response to the provided http.ResponseWriter.
WriteJsonSimple writes a simple JSON response with the provided status code.
WriteXml writes a simple XML response with the provided status code and data.
WriteXmlError writes an XML error response with the provided message and status code.
WriteXmlPaginated writes a paginated XML response to the provided http.ResponseWriter.

# Structs

ApiKeyMiddleware represents middleware for API key authentication.
ApiKeyUserMiddleware represents middleware for API key authentication.
BasicAuthMiddleware provides middleware for basic authentication.
No description provided by the author
HttpClient represents an HTTP request.
No description provided by the author
No description provided by the author
No description provided by the author
Response represents an HTTP response.
SessionGorilla handles sessions using gorilla/sessions.
SessionHttp stores session cookie details.
UserApiKey represents a user ID and its associated API key.
UserBasicAuth represents a user with username and password.
No description provided by the author