lambique

package module
v0.0.0-...-0a6e5f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

lambique

⚗ is an apparatus for web application written in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Mux http.Handler
}

App is an application.

func WithMux

func WithMux(mux http.Handler) *App

WithMux creates a new application with mux.

func (*App) Server

func (app *App) Server(addr string) *http.Server

Server creates a new server.

func (*App) Start

func (app *App) Start(addr string) error

Start serves a HTTP server.

type Config

type Config struct {
	Addr string `toml:"address"`
}

Config is a config for web application.

func GetConfig

func GetConfig() *Config

GetConfig returns the config.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads the config file from path and returns the config.

type ErrorResponse

type ErrorResponse struct {
	Type     string `json:"type"`
	Title    string `json:"title"`
	Status   int    `json:"status"`
	Detail   string `json:"detail"`
	Instance string `json:"instance"`
}

ErrorResponse represents an error based on RFC7807.

func NewErrorResponse

func NewErrorResponse(r *http.Request, err error, status int) *ErrorResponse

NewErrorResponse creates a new ErrorResponse.

func (*ErrorResponse) JSON

func (resp *ErrorResponse) JSON(w http.ResponseWriter) error

JSON writes the ErrorResponse as JSON.

func (*ErrorResponse) MustJSON

func (resp *ErrorResponse) MustJSON(w http.ResponseWriter)

MustJSON is like JSON but panics if the JSON encoder returns error.

type OffsetLimitPagination

type OffsetLimitPagination struct {
	OffsetKey string
	LimitKey  string
	PageSize  int
	Offset    int
	Limit     int
	// contains filtered or unexported fields
}

func NewOffsetLimitPagination

func NewOffsetLimitPagination() *OffsetLimitPagination
func (p *OffsetLimitPagination) FirstPagingLink(u *url.URL) (*PagingLink, error)
func (p *OffsetLimitPagination) LastPagingLink(u *url.URL) (*PagingLink, error)
func (p *OffsetLimitPagination) NextPagingLink(u *url.URL) (*PagingLink, error)
func (p *OffsetLimitPagination) PagingLinks(u *url.URL) (PagingLinks, error)

func (*OffsetLimitPagination) ParseURL

func (p *OffsetLimitPagination) ParseURL(u *url.URL) error
func (p *OffsetLimitPagination) PrevPagingLink(u *url.URL) (*PagingLink, error)

type PageNumberPagination

type PageNumberPagination struct {
	PageNumberKey string
	PageNumber    int
	// contains filtered or unexported fields
}

func NewPageNumberPagination

func NewPageNumberPagination() *PageNumberPagination
func (p *PageNumberPagination) FirstPagingLink(u *url.URL) (*PagingLink, error)
func (p *PageNumberPagination) LastPagingLink(u *url.URL) (*PagingLink, error)
func (p *PageNumberPagination) NextPagingLink(u *url.URL) (*PagingLink, error)
func (p *PageNumberPagination) PagingLinks(u *url.URL) (PagingLinks, error)

func (*PageNumberPagination) ParseURL

func (p *PageNumberPagination) ParseURL(u *url.URL) error
func (p *PageNumberPagination) PrevPagingLink(u *url.URL) (*PagingLink, error)

type Pagination

type Pagination interface {
	ParseURL(u *url.URL) error
	FirstPagingLink(u *url.URL) (*PagingLink, error)
	PrevPagingLink(u *url.URL) (*PagingLink, error)
	NextPagingLink(u *url.URL) (*PagingLink, error)
	LastPagingLink(u *url.URL) (*PagingLink, error)
	PagingLinks(u *url.URL) (PagingLinks, error)
}
type PagingLink struct {
	Rel string
	URL *url.URL
}

func (*PagingLink) String

func (link *PagingLink) String() string
type PagingLinks []*PagingLink

func (PagingLinks) String

func (ls PagingLinks) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL