dzeban / conduit Goto Github PK
View Code? Open in Web Editor NEWReal world app (medium clone) backend implemented in Go
License: MIT License
Real world app (medium clone) backend implemented in Go
License: MIT License
Currently, JWT contains 2 claims - "sub" and "signed". JWT must have expiration to avoid infinite tokens.
Logging middleware is needed to see requests on the server side.
It should log in logfmt (kv) or json format.
When quering user only email and username fields are returned.
CLI log:
(test) > user update bio=mystery
================================
PUT /users/ HTTP/1.1
Host: localhost:8080
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWduZWQiOnRydWUsInN1YiI6InRlc3RAZXhhbXBsZS5jb20ifQ.8dbE6VKua4RQsqJZXTqisRXCBf4K5dTgBgPYHwn1ikc
Content-Type: application/json
{
"user": {
"username": "",
"email": "",
"bio": "mystery"
}
}
--------------------------------
HTTP/1.1 200 OK
Content-Length: 201
Content-Type: text/plain; charset=utf-8
Date: Sun, 23 Jun 2019 20:24:30 GMT
{
"user": {
"username": "test",
"email": "[email protected]",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWduZWQiOnRydWUsInN1YiI6InRlc3RAZXhhbXBsZS5jb20ifQ.8dbE6VKua4RQsqJZXTqisRXCBf4K5dTgBgPYHwn1ikc"
}
}
================================
[update current user and token]
(test) > user get
================================
GET /users/ HTTP/1.1
Host: localhost:8080
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWduZWQiOnRydWUsInN1YiI6InRlc3RAZXhhbXBsZS5jb20ifQ.8dbE6VKua4RQsqJZXTqisRXCBf4K5dTgBgPYHwn1ikc
Content-Type: application/json
null
--------------------------------
HTTP/1.1 200 OK
Content-Length: 55
Content-Type: text/plain; charset=utf-8
Date: Sun, 23 Jun 2019 20:24:38 GMT
{
"user": {
"username": "test",
"email": "[email protected]"
}
}
================================
(test) > user update image=aaaa
================================
PUT /users/ HTTP/1.1
Host: localhost:8080
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWduZWQiOnRydWUsInN1YiI6InRlc3RAZXhhbXBsZS5jb20ifQ.8dbE6VKua4RQsqJZXTqisRXCBf4K5dTgBgPYHwn1ikc
Content-Type: application/json
{
"user": {
"username": "",
"email": "",
"image": "aaaa"
}
}
--------------------------------
HTTP/1.1 200 OK
Content-Length: 201
Content-Type: text/plain; charset=utf-8
Date: Sun, 23 Jun 2019 20:28:23 GMT
{
"user": {
"username": "test",
"email": "[email protected]",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWduZWQiOnRydWUsInN1YiI6InRlc3RAZXhhbXBsZS5jb20ifQ.8dbE6VKua4RQsqJZXTqisRXCBf4K5dTgBgPYHwn1ikc"
}
}
================================
[update current user and token]
(test) > user get
================================
GET /users/ HTTP/1.1
Host: localhost:8080
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWduZWQiOnRydWUsInN1YiI6InRlc3RAZXhhbXBsZS5jb20ifQ.8dbE6VKua4RQsqJZXTqisRXCBf4K5dTgBgPYHwn1ikc
Content-Type: application/json
null
--------------------------------
HTTP/1.1 200 OK
Content-Length: 55
Content-Type: text/plain; charset=utf-8
Date: Sun, 23 Jun 2019 20:28:27 GMT
{
"user": {
"username": "test",
"email": "[email protected]"
}
}
================================
Here is the db:
conduit=# select * from users where email='[email protected]';
id | name | email | bio | image | password
----+------+------------------+---------+-------+----------------------------------------------------------------------------------------------------------------------------------------------
1 | test | [email protected] | mystery | aaaa | $argon2id$v=19$m=32768,t=5,p=1$5W65rnCtWdAY6nmGX5Rz8g$gu5pIxhcGAUl6Nh8Fsow1G1pQMRT6Bya30miquBrlOG8sTnzuqmV960a7Wdbgij/tu6BpJTfjPjgFca1c9Csmw
I think it has something with sql.NullString because only these 2 fields are declared with this type:
var bio, image sql.NullString
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.