api

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

REST API v1

/v1/indexes

Index object:

{
    id: "the index ID"
    format: "pdf"
    tags: ["userABC", "salesTeam"]
    document: "a base64 encoded document, used for create new index only" 
    records: [{id: "abcd", segment: "hello world", vector: [1, 2]}]
}

An index record object:

{
    id: "a base64 encoded vector"
    segment: "this is searcheable piece of the text"
    vector: [1, "abc", 3]
}

Create new index

POST /v1/indexes

An index may be created via providing the whole data in the content-type: application/json body:

curl -XPOST -H "content-type: application/json" -d '{"id": "1234", "format": "pdf"}' http://localhost:8080/v1/indexes

or 'multipart/form-data' is also supported:

example:

curl -i -X POST -H "content-type: multipart/form-data" -F"file=@/Users/user/Downloads/fr_9782_size1024.jpg" -F "meta={\"id\": \"1234\", \"format\": \"jpg\"};type=application/json" http://localhost:8080/v1/indexes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAppJson added in v0.6.0

func BindAppJson(c *gin.Context, inf interface{}) error

BindAppJson turns the request body to inf, but for "application/json" contents only

func ComposeURI added in v0.6.0

func ComposeURI(r *http.Request, id string) string

ComposeURI helper function which composes URI, adding ID to the request path

func ParseTime added in v0.6.0

func ParseTime(s string) (time.Time, error)

func ResolveHost added in v0.6.0

func ResolveHost(r *http.Request) (host string)

ResolveHost returns host part of r

func ResolveScheme added in v0.6.0

func ResolveScheme(r *http.Request) string

ResolveScheme resolves initial request type by r

Types

type HttpEP

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

HttpEP provides the api endpoints for the HTTP interface

func NewHttpEP

func NewHttpEP(svc *Service) *HttpEP

func (*HttpEP) RegisterEPs

func (hep *HttpEP) RegisterEPs(g *gin.Engine) error

type Service

type Service struct {
	PProvider parser.Provider `inject:""`
	Db        persistence.Db  `inject:""`
	// contains filtered or unexported fields
}

Service implements the gRPC API endpoints

func NewService

func NewService() *Service

func (*Service) FormatServiceServer added in v0.6.0

func (s *Service) FormatServiceServer() format.ServiceServer

func (*Service) IndexServiceServer added in v0.6.0

func (s *Service) IndexServiceServer() index.ServiceServer

IndexServiceServer returns index.ServiceServer

Jump to

Keyboard shortcuts

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