policeuk

package module
v0.0.0-...-fb6681f Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 26 Imported by: 0

README

policeuk

A go library for accessing APIs exposed by the UK Police at data.police.uk.

This package is generated based around an OpenAPI spec created based around the API documentation available. This is because an OpenAPI spec is not provided by the UK Police.

Documentation

Overview

Code generated by ogen, DO NOT EDIT.

Index

Constants

View Source
const (
	ServerURL = "https://data.police.uk/api"
)

Variables

This section is empty.

Functions

func WithServerURL

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements OAS client.

func NewClient

func NewClient(serverURL string, opts ...ClientOption) (*Client, error)

NewClient initializes new Client defined by OAS.

func (*Client) GetDatasetAvailability

func (c *Client) GetDatasetAvailability(ctx context.Context) (DatasourceAvailability, error)

GetDatasetAvailability invokes getDatasetAvailability operation.

Get a list of available datasets by date and police force.

GET /crimes-street-dates

func (*Client) GetPoliceForce

func (c *Client) GetPoliceForce(ctx context.Context, params GetPoliceForceParams) (GetPoliceForceRes, error)

GetPoliceForce invokes getPoliceForce operation.

Get detailed information about a specific police force.

GET /forces/{forceId}

func (*Client) ListPoliceForces

func (c *Client) ListPoliceForces(ctx context.Context) (PoliceForces, error)

ListPoliceForces invokes listPoliceForces operation.

List all of the police forces available within the data.police.uk dataset.

GET /forces

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption is client config option.

func WithClient

func WithClient(client ht.Client) ClientOption

WithClient specifies http client to use.

type DatasourceAvailability

type DatasourceAvailability []DatasourceAvailabilityItem

func (*DatasourceAvailability) Decode

func (s *DatasourceAvailability) Decode(d *jx.Decoder) error

Decode decodes DatasourceAvailability from json.

func (DatasourceAvailability) Encode

func (s DatasourceAvailability) Encode(e *jx.Encoder)

Encode encodes DatasourceAvailability as json.

func (DatasourceAvailability) MarshalJSON

func (s DatasourceAvailability) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*DatasourceAvailability) UnmarshalJSON

func (s *DatasourceAvailability) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (DatasourceAvailability) Validate

func (s DatasourceAvailability) Validate() error

type DatasourceAvailabilityItem

type DatasourceAvailabilityItem struct {
	// ISO-8601 formatted year and date.
	Date OptString `json:"date"`
	// List of police forces providing stop and search information for the given month and year.
	StopAndSearch []string `json:"stop-and-search"`
}

func (*DatasourceAvailabilityItem) Decode

Decode decodes DatasourceAvailabilityItem from json.

func (*DatasourceAvailabilityItem) Encode

func (s *DatasourceAvailabilityItem) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*DatasourceAvailabilityItem) GetDate

GetDate returns the value of Date.

func (*DatasourceAvailabilityItem) GetStopAndSearch

func (s *DatasourceAvailabilityItem) GetStopAndSearch() []string

GetStopAndSearch returns the value of StopAndSearch.

func (*DatasourceAvailabilityItem) MarshalJSON

func (s *DatasourceAvailabilityItem) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*DatasourceAvailabilityItem) SetDate

func (s *DatasourceAvailabilityItem) SetDate(val OptString)

SetDate sets the value of Date.

func (*DatasourceAvailabilityItem) SetStopAndSearch

func (s *DatasourceAvailabilityItem) SetStopAndSearch(val []string)

SetStopAndSearch sets the value of StopAndSearch.

func (*DatasourceAvailabilityItem) UnmarshalJSON

func (s *DatasourceAvailabilityItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*DatasourceAvailabilityItem) Validate

func (s *DatasourceAvailabilityItem) Validate() error

type ErrorHandler

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type GetPoliceForceNotFound

type GetPoliceForceNotFound struct{}

GetPoliceForceNotFound is response for GetPoliceForce operation.

type GetPoliceForceParams

type GetPoliceForceParams struct {
	// ID of the police force to fetch information about.
	ForceId PoliceForceId
}

GetPoliceForceParams is parameters of getPoliceForce operation.

type GetPoliceForceRes

type GetPoliceForceRes interface {
	// contains filtered or unexported methods
}

type Handler

type Handler interface {
	// GetDatasetAvailability implements getDatasetAvailability operation.
	//
	// Get a list of available datasets by date and police force.
	//
	// GET /crimes-street-dates
	GetDatasetAvailability(ctx context.Context) (DatasourceAvailability, error)
	// GetPoliceForce implements getPoliceForce operation.
	//
	// Get detailed information about a specific police force.
	//
	// GET /forces/{forceId}
	GetPoliceForce(ctx context.Context, params GetPoliceForceParams) (GetPoliceForceRes, error)
	// ListPoliceForces implements listPoliceForces operation.
	//
	// List all of the police forces available within the data.police.uk dataset.
	//
	// GET /forces
	ListPoliceForces(ctx context.Context) (PoliceForces, error)
}

Handler handles operations described by OpenAPI v3 specification.

type Invoker

type Invoker interface {
	// GetDatasetAvailability invokes getDatasetAvailability operation.
	//
	// Get a list of available datasets by date and police force.
	//
	// GET /crimes-street-dates
	GetDatasetAvailability(ctx context.Context) (DatasourceAvailability, error)
	// GetPoliceForce invokes getPoliceForce operation.
	//
	// Get detailed information about a specific police force.
	//
	// GET /forces/{forceId}
	GetPoliceForce(ctx context.Context, params GetPoliceForceParams) (GetPoliceForceRes, error)
	// ListPoliceForces invokes listPoliceForces operation.
	//
	// List all of the police forces available within the data.police.uk dataset.
	//
	// GET /forces
	ListPoliceForces(ctx context.Context) (PoliceForces, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type Labeler

type Labeler struct {
	// contains filtered or unexported fields
}

Labeler is used to allow adding custom attributes to the server request metrics.

func LabelerFromContext

func LabelerFromContext(ctx context.Context) (*Labeler, bool)

LabelerFromContext retrieves the Labeler from the provided context, if present.

If no Labeler was found in the provided context a new, empty Labeler is returned and the second return value is false. In this case it is safe to use the Labeler but any attributes added to it will not be used.

func (*Labeler) Add

func (l *Labeler) Add(attrs ...attribute.KeyValue)

Add attributes to the Labeler.

func (*Labeler) AttributeSet

func (l *Labeler) AttributeSet() attribute.Set

AttributeSet returns the attributes added to the Labeler as an attribute.Set.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type OptNilPoliceForceEngagementMethodsItemArray

type OptNilPoliceForceEngagementMethodsItemArray struct {
	Value []PoliceForceEngagementMethodsItem
	Set   bool
	Null  bool
}

OptNilPoliceForceEngagementMethodsItemArray is optional nullable []PoliceForceEngagementMethodsItem.

func NewOptNilPoliceForceEngagementMethodsItemArray

func NewOptNilPoliceForceEngagementMethodsItemArray(v []PoliceForceEngagementMethodsItem) OptNilPoliceForceEngagementMethodsItemArray

NewOptNilPoliceForceEngagementMethodsItemArray returns new OptNilPoliceForceEngagementMethodsItemArray with value set to v.

func (*OptNilPoliceForceEngagementMethodsItemArray) Decode

Decode decodes []PoliceForceEngagementMethodsItem from json.

func (OptNilPoliceForceEngagementMethodsItemArray) Encode

Encode encodes []PoliceForceEngagementMethodsItem as json.

func (OptNilPoliceForceEngagementMethodsItemArray) Get

Get returns value and boolean that denotes whether value was set.

func (OptNilPoliceForceEngagementMethodsItemArray) IsNull

IsSet returns true if value is Null.

func (OptNilPoliceForceEngagementMethodsItemArray) IsSet

IsSet returns true if OptNilPoliceForceEngagementMethodsItemArray was set.

func (OptNilPoliceForceEngagementMethodsItemArray) MarshalJSON

MarshalJSON implements stdjson.Marshaler.

func (OptNilPoliceForceEngagementMethodsItemArray) Or

Or returns value if set, or given parameter if does not.

func (*OptNilPoliceForceEngagementMethodsItemArray) Reset

Reset unsets value.

func (*OptNilPoliceForceEngagementMethodsItemArray) SetTo

SetTo sets value to v.

func (*OptNilPoliceForceEngagementMethodsItemArray) SetToNull

SetNull sets value to null.

func (*OptNilPoliceForceEngagementMethodsItemArray) UnmarshalJSON

func (s *OptNilPoliceForceEngagementMethodsItemArray) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptNilString

type OptNilString struct {
	Value string
	Set   bool
	Null  bool
}

OptNilString is optional nullable string.

func NewOptNilString

func NewOptNilString(v string) OptNilString

NewOptNilString returns new OptNilString with value set to v.

func (*OptNilString) Decode

func (o *OptNilString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptNilString) Encode

func (o OptNilString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptNilString) Get

func (o OptNilString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptNilString) IsNull

func (o OptNilString) IsNull() bool

IsSet returns true if value is Null.

func (OptNilString) IsSet

func (o OptNilString) IsSet() bool

IsSet returns true if OptNilString was set.

func (OptNilString) MarshalJSON

func (s OptNilString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptNilString) Or

func (o OptNilString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*OptNilString) Reset

func (o *OptNilString) Reset()

Reset unsets value.

func (*OptNilString) SetTo

func (o *OptNilString) SetTo(v string)

SetTo sets value to v.

func (*OptNilString) SetToNull

func (o *OptNilString) SetToNull()

SetNull sets value to null.

func (*OptNilString) UnmarshalJSON

func (s *OptNilString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptNilURI

type OptNilURI struct {
	Value url.URL
	Set   bool
	Null  bool
}

OptNilURI is optional nullable url.URL.

func NewOptNilURI

func NewOptNilURI(v url.URL) OptNilURI

NewOptNilURI returns new OptNilURI with value set to v.

func (*OptNilURI) Decode

func (o *OptNilURI) Decode(d *jx.Decoder) error

Decode decodes url.URL from json.

func (OptNilURI) Encode

func (o OptNilURI) Encode(e *jx.Encoder)

Encode encodes url.URL as json.

func (OptNilURI) Get

func (o OptNilURI) Get() (v url.URL, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptNilURI) IsNull

func (o OptNilURI) IsNull() bool

IsSet returns true if value is Null.

func (OptNilURI) IsSet

func (o OptNilURI) IsSet() bool

IsSet returns true if OptNilURI was set.

func (OptNilURI) MarshalJSON

func (s OptNilURI) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptNilURI) Or

func (o OptNilURI) Or(d url.URL) url.URL

Or returns value if set, or given parameter if does not.

func (*OptNilURI) Reset

func (o *OptNilURI) Reset()

Reset unsets value.

func (*OptNilURI) SetTo

func (o *OptNilURI) SetTo(v url.URL)

SetTo sets value to v.

func (*OptNilURI) SetToNull

func (o *OptNilURI) SetToNull()

SetNull sets value to null.

func (*OptNilURI) UnmarshalJSON

func (s *OptNilURI) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptPoliceForceId

type OptPoliceForceId struct {
	Value PoliceForceId
	Set   bool
}

OptPoliceForceId is optional PoliceForceId.

func NewOptPoliceForceId

func NewOptPoliceForceId(v PoliceForceId) OptPoliceForceId

NewOptPoliceForceId returns new OptPoliceForceId with value set to v.

func (*OptPoliceForceId) Decode

func (o *OptPoliceForceId) Decode(d *jx.Decoder) error

Decode decodes PoliceForceId from json.

func (OptPoliceForceId) Encode

func (o OptPoliceForceId) Encode(e *jx.Encoder)

Encode encodes PoliceForceId as json.

func (OptPoliceForceId) Get

func (o OptPoliceForceId) Get() (v PoliceForceId, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptPoliceForceId) IsSet

func (o OptPoliceForceId) IsSet() bool

IsSet returns true if OptPoliceForceId was set.

func (OptPoliceForceId) MarshalJSON

func (s OptPoliceForceId) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptPoliceForceId) Or

Or returns value if set, or given parameter if does not.

func (*OptPoliceForceId) Reset

func (o *OptPoliceForceId) Reset()

Reset unsets value.

func (*OptPoliceForceId) SetTo

func (o *OptPoliceForceId) SetTo(v PoliceForceId)

SetTo sets value to v.

func (*OptPoliceForceId) UnmarshalJSON

func (s *OptPoliceForceId) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptPoliceForceName

type OptPoliceForceName struct {
	Value PoliceForceName
	Set   bool
}

OptPoliceForceName is optional PoliceForceName.

func NewOptPoliceForceName

func NewOptPoliceForceName(v PoliceForceName) OptPoliceForceName

NewOptPoliceForceName returns new OptPoliceForceName with value set to v.

func (*OptPoliceForceName) Decode

func (o *OptPoliceForceName) Decode(d *jx.Decoder) error

Decode decodes PoliceForceName from json.

func (OptPoliceForceName) Encode

func (o OptPoliceForceName) Encode(e *jx.Encoder)

Encode encodes PoliceForceName as json.

func (OptPoliceForceName) Get

func (o OptPoliceForceName) Get() (v PoliceForceName, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptPoliceForceName) IsSet

func (o OptPoliceForceName) IsSet() bool

IsSet returns true if OptPoliceForceName was set.

func (OptPoliceForceName) MarshalJSON

func (s OptPoliceForceName) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptPoliceForceName) Or

Or returns value if set, or given parameter if does not.

func (*OptPoliceForceName) Reset

func (o *OptPoliceForceName) Reset()

Reset unsets value.

func (*OptPoliceForceName) SetTo

func (o *OptPoliceForceName) SetTo(v PoliceForceName)

SetTo sets value to v.

func (*OptPoliceForceName) UnmarshalJSON

func (s *OptPoliceForceName) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

func (o *OptString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptString) Encode

func (o OptString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptString) Get

func (o OptString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON

func (s OptString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or

func (o OptString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON

func (s *OptString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the otel.GetMeterProvider() is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

type PoliceForce

type PoliceForce struct {
	// Descriptive information about a police force. This can sometimes contain markup.
	Description OptNilString `json:"description"`
	// The police force's website URL.
	URL OptNilURI `json:"url"`
	// Police force's non-emergency contact telephone number.
	Telephone OptNilString       `json:"telephone"`
	ID        OptPoliceForceId   `json:"id"`
	Name      OptPoliceForceName `json:"name"`
	// List of ways to be informed about the police force.
	EngagementMethods OptNilPoliceForceEngagementMethodsItemArray `json:"engagement_methods"`
}

Ref: #/components/schemas/PoliceForce

func (*PoliceForce) Decode

func (s *PoliceForce) Decode(d *jx.Decoder) error

Decode decodes PoliceForce from json.

func (*PoliceForce) Encode

func (s *PoliceForce) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*PoliceForce) GetDescription

func (s *PoliceForce) GetDescription() OptNilString

GetDescription returns the value of Description.

func (*PoliceForce) GetEngagementMethods

func (s *PoliceForce) GetEngagementMethods() OptNilPoliceForceEngagementMethodsItemArray

GetEngagementMethods returns the value of EngagementMethods.

func (*PoliceForce) GetID

func (s *PoliceForce) GetID() OptPoliceForceId

GetID returns the value of ID.

func (*PoliceForce) GetName

func (s *PoliceForce) GetName() OptPoliceForceName

GetName returns the value of Name.

func (*PoliceForce) GetTelephone

func (s *PoliceForce) GetTelephone() OptNilString

GetTelephone returns the value of Telephone.

func (*PoliceForce) GetURL

func (s *PoliceForce) GetURL() OptNilURI

GetURL returns the value of URL.

func (*PoliceForce) MarshalJSON

func (s *PoliceForce) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PoliceForce) SetDescription

func (s *PoliceForce) SetDescription(val OptNilString)

SetDescription sets the value of Description.

func (*PoliceForce) SetEngagementMethods

func (s *PoliceForce) SetEngagementMethods(val OptNilPoliceForceEngagementMethodsItemArray)

SetEngagementMethods sets the value of EngagementMethods.

func (*PoliceForce) SetID

func (s *PoliceForce) SetID(val OptPoliceForceId)

SetID sets the value of ID.

func (*PoliceForce) SetName

func (s *PoliceForce) SetName(val OptPoliceForceName)

SetName sets the value of Name.

func (*PoliceForce) SetTelephone

func (s *PoliceForce) SetTelephone(val OptNilString)

SetTelephone sets the value of Telephone.

func (*PoliceForce) SetURL

func (s *PoliceForce) SetURL(val OptNilURI)

SetURL sets the value of URL.

func (*PoliceForce) UnmarshalJSON

func (s *PoliceForce) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*PoliceForce) Validate

func (s *PoliceForce) Validate() error

type PoliceForceEngagementMethodsItem

type PoliceForceEngagementMethodsItem struct {
	// URL of the engagement method.
	URL OptNilString `json:"url"`
	// Descriptive information about the police force's engagement method.
	Description OptNilString `json:"description"`
	// Title of the engagement method.
	Title OptString `json:"title"`
}

func (*PoliceForceEngagementMethodsItem) Decode

Decode decodes PoliceForceEngagementMethodsItem from json.

func (*PoliceForceEngagementMethodsItem) Encode

Encode implements json.Marshaler.

func (*PoliceForceEngagementMethodsItem) GetDescription

func (s *PoliceForceEngagementMethodsItem) GetDescription() OptNilString

GetDescription returns the value of Description.

func (*PoliceForceEngagementMethodsItem) GetTitle

GetTitle returns the value of Title.

func (*PoliceForceEngagementMethodsItem) GetURL

GetURL returns the value of URL.

func (*PoliceForceEngagementMethodsItem) MarshalJSON

func (s *PoliceForceEngagementMethodsItem) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PoliceForceEngagementMethodsItem) SetDescription

func (s *PoliceForceEngagementMethodsItem) SetDescription(val OptNilString)

SetDescription sets the value of Description.

func (*PoliceForceEngagementMethodsItem) SetTitle

SetTitle sets the value of Title.

func (*PoliceForceEngagementMethodsItem) SetURL

SetURL sets the value of URL.

func (*PoliceForceEngagementMethodsItem) UnmarshalJSON

func (s *PoliceForceEngagementMethodsItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type PoliceForceId

type PoliceForceId string

func (*PoliceForceId) Decode

func (s *PoliceForceId) Decode(d *jx.Decoder) error

Decode decodes PoliceForceId from json.

func (PoliceForceId) Encode

func (s PoliceForceId) Encode(e *jx.Encoder)

Encode encodes PoliceForceId as json.

func (PoliceForceId) MarshalJSON

func (s PoliceForceId) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PoliceForceId) UnmarshalJSON

func (s *PoliceForceId) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type PoliceForceName

type PoliceForceName string

func (*PoliceForceName) Decode

func (s *PoliceForceName) Decode(d *jx.Decoder) error

Decode decodes PoliceForceName from json.

func (PoliceForceName) Encode

func (s PoliceForceName) Encode(e *jx.Encoder)

Encode encodes PoliceForceName as json.

func (PoliceForceName) MarshalJSON

func (s PoliceForceName) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PoliceForceName) UnmarshalJSON

func (s *PoliceForceName) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type PoliceForces

type PoliceForces []PoliceForcesItem

func (*PoliceForces) Decode

func (s *PoliceForces) Decode(d *jx.Decoder) error

Decode decodes PoliceForces from json.

func (PoliceForces) Encode

func (s PoliceForces) Encode(e *jx.Encoder)

Encode encodes PoliceForces as json.

func (PoliceForces) MarshalJSON

func (s PoliceForces) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PoliceForces) UnmarshalJSON

func (s *PoliceForces) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (PoliceForces) Validate

func (s PoliceForces) Validate() error

type PoliceForcesItem

type PoliceForcesItem struct {
	ID   OptPoliceForceId   `json:"id"`
	Name OptPoliceForceName `json:"name"`
}

func (*PoliceForcesItem) Decode

func (s *PoliceForcesItem) Decode(d *jx.Decoder) error

Decode decodes PoliceForcesItem from json.

func (*PoliceForcesItem) Encode

func (s *PoliceForcesItem) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*PoliceForcesItem) GetID

GetID returns the value of ID.

func (*PoliceForcesItem) GetName

func (s *PoliceForcesItem) GetName() OptPoliceForceName

GetName returns the value of Name.

func (*PoliceForcesItem) MarshalJSON

func (s *PoliceForcesItem) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*PoliceForcesItem) SetID

func (s *PoliceForcesItem) SetID(val OptPoliceForceId)

SetID sets the value of ID.

func (*PoliceForcesItem) SetName

func (s *PoliceForcesItem) SetName(val OptPoliceForceName)

SetName sets the value of Name.

func (*PoliceForcesItem) UnmarshalJSON

func (s *PoliceForcesItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Route

type Route struct {
	// contains filtered or unexported fields
}

Route is route object.

func (Route) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

func (Route) Summary

func (r Route) Summary() string

Summary returns OpenAPI summary.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.

func NewServer

func NewServer(h Handler, opts ...ServerOption) (*Server, error)

NewServer creates new Server.

func (*Server) FindPath

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption is server config option.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory

func WithMaxMultipartMemory(max int64) ServerOption

WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.

func WithMethodNotAllowed

func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type UnimplementedHandler

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) GetDatasetAvailability

func (UnimplementedHandler) GetDatasetAvailability(ctx context.Context) (r DatasourceAvailability, _ error)

GetDatasetAvailability implements getDatasetAvailability operation.

Get a list of available datasets by date and police force.

GET /crimes-street-dates

func (UnimplementedHandler) GetPoliceForce

GetPoliceForce implements getPoliceForce operation.

Get detailed information about a specific police force.

GET /forces/{forceId}

func (UnimplementedHandler) ListPoliceForces

func (UnimplementedHandler) ListPoliceForces(ctx context.Context) (r PoliceForces, _ error)

ListPoliceForces implements listPoliceForces operation.

List all of the police forces available within the data.police.uk dataset.

GET /forces

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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