Documentation ¶
Index ¶
- func AbsolutePath(dir string, path string) string
- func AddContentDisposition(w http.ResponseWriter, filename string)
- func AddContentDispositionSong(w http.ResponseWriter, metadata, filename string)
- func ChangeRequestMethod(r *http.Request, method string) *http.Request
- func IsHTMX(r *http.Request) bool
- func OneOff[T any](ctx context.Context, fn StreamFn[T]) (T, error)
- func RedirectBack(r *http.Request) *http.Request
- func RedirectToServer(w http.ResponseWriter, r *http.Request) error
- func ReduceHasLeftover[T any](s []T, step int) bool
- func ReduceWithStep[T any](s []T, step int) []T
- func RestoreOrListen(store *fdstore.Store, name string, network, addr string) (net.Listener, []byte, error)
- func Signal(signals ...os.Signal) <-chan os.Signal
- type CallbackTimer
- type Map
- func (m *Map[K, V]) CompareAndDelete(key K, old V) (deleted bool)
- func (m *Map[K, V]) CompareAndSwap(key K, old V, new V) bool
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Load(key K) (value V, ok bool)
- func (m *Map[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *Map[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (m *Map[K, V]) Range(fn func(key K, value V) bool)
- func (m *Map[K, V]) Store(key K, value V)
- func (m *Map[K, V]) Swap(key K, value V) (previous V, loaded bool)
- type StreamCallbackFn
- type StreamFn
- type TypedValue
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsolutePath ¶
func AddContentDisposition ¶
func AddContentDisposition(w http.ResponseWriter, filename string)
func AddContentDispositionSong ¶
func AddContentDispositionSong(w http.ResponseWriter, metadata, filename string)
func OneOff ¶
OneOff creates a stream through fn and returns the first value received after which it closes the stream. Should be used where you only need a very sporadic value that is supplied by a streaming API.
func RedirectToServer ¶
func RedirectToServer(w http.ResponseWriter, r *http.Request) error
RedirectToServer looks up the http.Server associated with this request and calls ServeHTTP again
func ReduceHasLeftover ¶
func ReduceWithStep ¶
func RestoreOrListen ¶
func RestoreOrListen(store *fdstore.Store, name string, network, addr string) (net.Listener, []byte, error)
RestoreOrListen tries to restore a listener with the name given from the store given. If any error occurs it instead just calls net.Listen with the provided arguments network and addr
Types ¶
type CallbackTimer ¶
type CallbackTimer struct {
// contains filtered or unexported fields
}
func NewCallbackTimer ¶
func NewCallbackTimer(callback func()) *CallbackTimer
func (*CallbackTimer) Start ¶
func (tc *CallbackTimer) Start(timeout time.Duration)
Start starts a timer with the timeout given, if a timer is already running it is stopped and a new timer is created
func (*CallbackTimer) Stop ¶
func (tc *CallbackTimer) Stop() bool
Stop stops the current timer if one exists
type Map ¶
type Map[K, V any] struct { // contains filtered or unexported fields }
func (*Map[K, V]) CompareAndDelete ¶
func (*Map[K, V]) CompareAndSwap ¶
func (*Map[K, V]) LoadAndDelete ¶
func (*Map[K, V]) LoadOrStore ¶
type StreamCallbackFn ¶
type TypedValue ¶
type TypedValue[T any] struct { // contains filtered or unexported fields }
func NewTypedValue ¶
func NewTypedValue[T any](initial T) *TypedValue[T]
func (*TypedValue[T]) Load ¶
func (tv *TypedValue[T]) Load() T
func (*TypedValue[T]) Store ¶
func (tv *TypedValue[T]) Store(new T)
func (*TypedValue[T]) Swap ¶
func (tv *TypedValue[T]) Swap(newv T) (old T)
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
func StreamValue ¶
func StreamValue[T any](ctx context.Context, fn StreamFn[T], callbackFn ...StreamCallbackFn[T]) *Value[T]
StreamValue opens the stream created by StreamFn and calls any callbackFn given everytime a new value is returned by the stream. StreamValue also stores the last received value, accessable by calling .Latest