Documentation ¶
Overview ¶
* Copyright (c) 2020. Denis Rendler <connect@rendler.me> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright (c) 2020. Denis Rendler <connect@rendler.me> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright (c) 2020. Denis Rendler <connect@rendler.me> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright (c) 2020. Denis Rendler <connect@rendler.me> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
Constants ¶
const ( StoredTemplate = "new_note.gohtml" FetchedTemplate = "note_read.gohtml" )
const ( StoreEvent = "new_note" FetchEvent = "note_read" )
const ( ExpireOnRead = "on-read" ExpireAfter5M = "5m" ExpireAfter30M = "30m" ExpireAfter1H = "1h" ExpireAfter1DAY = "24h" ExpireAfter2DAY = "48h" ExpireAfter7DAY = "168h" )
Variables ¶
var ErrNotFound = errors.New("note not found")
Functions ¶
func InitSketch ¶
Types ¶
type ContentMessage ¶
ContentMessage is an API representation of note content stored
type InputMessage ¶
type InputMessage struct { Content string `json:"content" validate:"required,min=1"` AutoExpire string `json:"auto-expire,omitempty" validate:"omitempty,expire-interval"` Notify Notification `json:"notify,omitempty"` }
InputMessage is an API representation of incoming note data and options
func (*InputMessage) IsAutoExpire ¶
func (in *InputMessage) IsAutoExpire() bool
func (*InputMessage) IsValid ¶
func (in *InputMessage) IsValid() (bool, []string)
InputMessage.IsValid is used to validate data passed from the client
type LinkMessage ¶
LinkMessage is an API representation of successful storage of note and options
type MemoryRepo ¶
type MemoryRepo struct {
// contains filtered or unexported fields
}
func NewMemoryRepo ¶
func NewMemoryRepo() *MemoryRepo
func (MemoryRepo) FetchByID ¶
func (s MemoryRepo) FetchByID(id string) (*Note, error)
FetchByID retrieves a note based on it's ID
func (*MemoryRepo) Pop ¶
func (s *MemoryRepo) Pop(id string) (*Note, error)
Pop is used to retrieve a note and remove it from the collection at the same time
func (*MemoryRepo) Store ¶
func (s *MemoryRepo) Store(note *Note) (*Note, error)
Store retrieves a note based on it's ID
func (*MemoryRepo) StoreWithTimeout ¶
func (s *MemoryRepo) StoreWithTimeout(note *Note, until string) (*Note, error)
type Note ¶
Note type used for defining a note
func NewNote ¶
func NewNote(opts ...NoteOptions) *Note
type NoteEvent ¶
type NoteEvent struct {
// contains filtered or unexported fields
}
func NewFetchedEvent ¶
func NewStoredEvent ¶
func (NoteEvent) GetPayload ¶
func (n NoteEvent) GetPayload() interface{}
type NoteOptions ¶
type NoteOptions func(*Note)
func FromInput ¶
func FromInput(input InputMessage) NoteOptions
type Notification ¶
type Repository ¶
type WebApi ¶
type WebApi struct {
// contains filtered or unexported fields
}
NotesWebApi controller
func NewWebApi ¶
func NewWebApi(repository Repository, evStream ev.Broker) *WebApi
NewWebApi initialize a new controller
func (WebApi) RegisterRoutes ¶
RegisterRoutes the Notes api endpoints