Skip to content

Instantly share code, notes, and snippets.

View d-vignesh's full-sized avatar

vignesh d-vignesh

  • Bangalore
View GitHub Profile
openapi: 3.0.0
info:
title: Todo app OAS
description: OpenApi specification for a todo application
version: 1.0.0
servers:
- url: http://localhost:32208/
// Package main provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.8.1 DO NOT EDIT.
package main
import (
"time"
)
// Defines values for TodoStatus.
// GetTodos operation middleware
func (siw *ServerInterfaceWrapper) GetTodos(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// Parameter object where we will unmarshal all parameters from the context
var params GetTodosParams
// ------------- Required query parameter "user" -------------
// Handler creates http.Handler with routing matching OpenAPI spec.
func Handler(si ServerInterface) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{})
}
package main
import "net/http"
type TodoServer struct {
}
func (t TodoServer) GetTodos(w http.ResponseWriter, r *http.Request, params GetTodosParams) {
// our logic to retrieve all todos from a persistent layer
}
// ServerInterfaceWrapper converts contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
}
// HandlerWithOptions creates http.Handler with additional options
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {
r := options.BaseRouter
syntax = "proto3";
package api;
enum TaskState {
TASK_OPEN = 0;
TASK_IN_PROGRESS = 1;
TASK_DONE = 2;
TASK_POST_PONED = 3;
}
package domain
import (
"github.com/google/uuid"
)
type Pet struct {
ID uuid.UUID `json:"id" bson:"id,omitempty"`
Category string `json:"category" bson:"category,omitempty"`
Breed string `json:"breed" bson:"breed,omitempty"`
package app
import (
"github.com/d-vignesh/getpets/pkg/domain"
"github.com/google/uuid"
)
// petSvc implements domain.PetSvc
type petSvc struct {
DB domain.PetDB
package db
import (
"github.com/d-vignesh/getpets/pkg/domain"
"github.com/google/uuid"
"github.com/pkg/errors"
)
// inMemStore implements domain.PetDB with an memory storage
type inMemStore struct {