api

package
v0.0.0-...-1f1cd5d Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 19 Imported by: 0

README

API Reference

Current API version is v1. All endpoints should be prefixed with /api/v1.

Authentication

Most of available endpoints requires user to be authenticated.

Currently, standard JWT auth is used: Authorization request header should have value Bearer <token>.

Endpoints

Debug endpoints
GET /api/v1/echo

Responds with "OK" on each request.

$ curl http://localhost:8010/api/v1/echo
OK
GET /api/v1/auth-echo

Responds with "OK" on each request with valid JWT.

$ curl http://localhost:8010/api/v1/auth-echo -H "Authorization: Bearer $TOKEN"
OK
User endpoints
POST /api/v1/wisher

Create new user.

POST /api/v1/login

Authorize user.

For details see user API reference.

Documentation

Overview

Package api contains top-level domain API, not used by any other domain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State holds general application state.

func Init

func Init(ctx context.Context, configPath string) (*State, error)

Init initializes API and returns new API instance.

func (*State) Config

func (s *State) Config() *configSchema.Configuration

Config returns server configuration.

func (*State) Logger

func (*State) Logger() *log.Logger

Logger returns configured logger.

func (*State) Server

func (s *State) Server(ctx context.Context) (*http.Server, error)

Server creates new API server instance.

func (*State) Service

func (s *State) Service(id svcSchema.ServiceID) any

Service returns exact service instance by ID.

func (*State) Storage

func (s *State) Storage() storageSchema.QueryExecutor

Storage returns shared query executor (i.e. *sqlx.DB).

Directories

Path Synopsis
cmd
server
Package main is a script to start API server.
Package main is a script to start API server.
Package commonhandlers contains unscoped API handlers
Package commonhandlers contains unscoped API handlers
Package errorhandler contains handler for handler-produced errors
Package errorhandler contains handler for handler-produced errors
Package middlewares provides middlewares to be used by server.
Package middlewares provides middlewares to be used by server.

Jump to

Keyboard shortcuts

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