Skip to content

Instantly share code, notes, and snippets.

@paprikati
paprikati / error_with_urgency.go
Last active Apr 13, 2022
At incident.io, we use Sentry to manage our exceptions, and PagerDuty to handle our on-call rota and escalate to an engineer. This code allows us to set the 'urgency' on an error, and apply rules in Sentry so we don't page on specific errors.
View error_with_urgency.go
package errors
import "context"
// ErrorWithUrgency represents an error with a specified urgency. We currently
// support two urgencies:
// page - this means we will escalate to the on-call engineer. This is the default behaviour.
// sentry - this means we will send it to Sentry, but won't page someone.
type ErrorWithUrgency struct {
cause error
@paprikati
paprikati / check_organisation_scope.go
Last active Dec 3, 2021
CheckOrganisationScope: using middleware to check that API responses are scoped by organisation ID
View check_organisation_scope.go
package mw
import (
"context"
"reflect"
"github.com/incident-io/core/server/api/gen/billing"
"github.com/incident-io/core/server/api/gen/insights"
"github.com/incident-io/core/server/api/gen/system"
"github.com/incident-io/core/server/api/gen/typeaheads"
@paprikati
paprikati / readme.MD
Last active Nov 23, 2021
safedb: using a gorm hook to check that queries are scoped by organisation ID
View readme.MD

SafeDB

This gist is associated with the blog post "Building safe-by-default tools in our Go web application".

It contains the gorm hooks that we use to ensure our queries are correctly scoped.

View test_pdf.json
{
"content": [
{
"text": "Long Text",
"style": "h1",
"margin": [
5,
5,
5,
20
@paprikati
paprikati / test_pdf.json
Created Nov 6, 2019
PDF Make unbreakable test
View test_pdf.json
{
"content": [
{
"text": "Long Text",
"style": "h1",
"margin": [
5,
5,
5,
20