Documentation ¶
Index ¶
Constants ¶
const (
BASE_PREMAR = "https://premar.antoine-augusti.fr"
)
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type AVURNAV ¶
type AVURNAV struct { // Number is the number of the AVURNAV. This is the main public identifier Number string `json:"number"` // Title is the title of the AVURNAV Title string `json:"title"` // Content is the content of the AVURNAV Content string `json:"content"` // Latitude gives an indication about the localisation of the AVURNAV. // It's not super reliable for now because AVURNAVs can spawn multiple // geographical regions but for now Préfet Maritimes only give a single point. Latitude float32 `json:"latitude"` // Longitude gives an indication about the localisation of the AVURNAV. // It's not super reliable for now because AVURNAVs can spawn multiple // geographical regions but for now Préfet Maritimes only give a single point. Longitude float32 `json:"longitude"` // URL gives a full URL to a Préfet Maritime website concerning this specific AVURNAV URL string `json:"url"` // ValidFrom tells when the AVURNAV will be in force. Format: YYYY-MM-DD ValidFrom *string `json:"valid_from"` // ValidUntil tells when the AVURNAV will not be valid anymore. Format: YYYY-MM-DD ValidUntil *string `json:"valid_until"` // PreMarRegion gives the region under the authority of this Préfet Maritime PreMarRegion string `json:"premar_region"` }
AVURNAV represents an AVURNAV
func (AVURNAV) MarshalBinary ¶
MarshalBinary marshals the object
func (AVURNAV) ParseContent ¶
ParseContent fills the content section of an AVURNAV and returns a new one
func (*AVURNAV) UnmarshalBinary ¶
UnmarshalBinary unmarshals the object
type AVURNAVFetcher ¶
type AVURNAVFetcher struct {
// contains filtered or unexported fields
}
AVURNAVFetcher fetches AVURNAVs on the Préfet Maritime websites
type AVURNAVPayload ¶
type AVURNAVPayload struct { Title string `json:"title"` ValidFrom string `json:"valid_from"` ValidUntil string `json:"valid_until"` Latitude float32 `json:"latitude"` Longitude float32 `json:"longitude"` URL string `json:"url"` Number string `json:"number"` }
AVURNAVPayload is used to decode AVURNAVs from the Préfet Maritime websites
func (AVURNAVPayload) AVURNAV ¶
func (p AVURNAVPayload) AVURNAV(premar PremarInterface) AVURNAV
AVURNAV transforms a payload to a proper AVURNAV
type AVURNAVPayloads ¶
type AVURNAVPayloads []AVURNAVPayload
AVURNAVPayloads represents multiple AVRUNAV payloads
func (AVURNAVPayloads) AVURNAVs ¶
func (p AVURNAVPayloads) AVURNAVs(premar PremarInterface) AVURNAVs
AVURNAVs transforms payloads to AVURNAVs
type Client ¶
type Client struct { // User agent for client UserAgent string // Services used for communications with the API Manche AVURNAVFetcher Atlantique AVURNAVFetcher Mediterranee AVURNAVFetcher Fetchers []*AVURNAVFetcher // contains filtered or unexported fields }
Client manages communication with the API
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
type ErrorResponse ¶
type ErrorResponse struct { // Response is the HTTP response that caused this error Response *http.Response // Message is the error message Message string }
ErrorResponse reports the error caused by an API request
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
Error gives information about the error
type PremarInterface ¶
type PremarInterface interface { // Client gets the HTTP client Client() *Client // BaseURL returns the base URL of the website BaseURL() *url.URL // Region returns the region under the authority of // the Préfet Maritime Region() string }
PremarInterface describes which data a Préfet Maritime service should be able to give
type PremarService ¶
type PremarService struct {
// contains filtered or unexported fields
}
PremarService gives information about a specific Préfet Maritime
func (PremarService) BaseURL ¶
func (s PremarService) BaseURL() *url.URL
BaseURL returns the base URL of the website
func (PremarService) Region ¶
func (s PremarService) Region() string
Region returns the region under the authority of the Préfet Maritime
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage stores AVURNAVs in Redis
func NewStorage ¶
NewStorage constructs a new Storage from a Redis client
func (*Storage) AVURNAVsForRegion ¶
AVURNAVsForRegion lists AVURNAVs for a specific Préfet Maritime region
func (*Storage) RegisterAVURNAVs ¶
RegisterAVURNAVs stores AVURNAVs in storage