Problem statement https://codingchallenges.fyi/challenges/challenge-keep/ Writeup https://srinjoysantra.live/blog/go-keep
- Directory structure
- Dependency injection
- Request interceptors
- API
- HTTP
- Ouath2 with Auht0
- Session based on cookie
- HTTP
- Vendoring
- Commenting
- Containerizing
- Logging
- Error
- Tracing
- Documenting
- Unit Testing
- Integration testing
The general philosophy of it was not to use various HTTP rest client libraries like gin / echo / etc and use fully embrace net/http
- Auth https://www.authgear.com/post/authentication-as-a-service
- Social login https://developer.auth0.com/resources/code-samples/api/standard-library/basic-authorization
- API best practices https://grafana.com/blog/2024/02/09/how-i-write-http-services-in-go-after-13-years/
- https://12factor.net
- status code https://www.restapitutorial.com/httpstatuscodes.html
- rest best practices https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/#h-handle-errors-gracefully-and-return-standard-error-codes
- https://restfulapi.net/http-methods
https://www.postgresql.org/docs/16/index.html
CREATE TABLE Note(
id UUID NOT NULL,
title TEXT NOT NULL,
content TEXT NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);
CREATE FUNCTION update_updated_at_note()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER update_note_updated_at
BEFORE UPDATE
ON
note
FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_note();
INSERT INTO Note VALUES('018de613-34ef-79ed-874b-2196c5d5167a', 'first note', '# Heading 1 ## Heading 2 body');
SELECT * FROM note WHERE apiid='018de613-34ef-79ed-874b-2196c5d5167a';
UPDATE Note SET title = "Updated note", content="Why do I want to update?" WHERE apiid='018de613-34ef-79ed-874b-2196c5d5167a';
- OAuth 2.0 and OpenID Connect (in plain English) YT video
- Auth0 alternatives
- Gorilla session (Used in auth0 example)
- https://github.com/alexedwards/scs
- https://www.reddit.com/r/golang/comments/111i0ps/what_are_the_best_alternatives_to_gorilla_session/
- https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/06.1.html
- https://www.reddit.com/r/golang/comments/13yrkr6/authentication_with_nethttp_package/
- https://github.com/Acebond/session
- https://www.alexedwards.net/blog/working-with-cookies-in-go
Where to deploy