{"id":15324868,"url":"https://github.com/hongjungwan/http-handler-modules","last_synced_at":"2025-03-27T14:44:16.886Z","repository":{"id":248245906,"uuid":"828124517","full_name":"HongJungWan/http-handler-modules","owner":"HongJungWan","description":"H𝚝𝚝𝚙 H𝚊𝚗𝚍𝚕𝚎𝚛 M𝚘𝚍𝚞𝚕𝚎𝚜 📚","archived":false,"fork":false,"pushed_at":"2024-08-02T09:46:21.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T18:43:56.548Z","etag":null,"topics":["docker","github-action","go","golang","http","jwt","redis","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HongJungWan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-13T07:31:16.000Z","updated_at":"2024-08-10T08:17:17.000Z","dependencies_parsed_at":"2024-07-28T02:57:46.809Z","dependency_job_id":"93f26a32-0aea-406f-ab51-b7f67006fb53","html_url":"https://github.com/HongJungWan/http-handler-modules","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"86b39b6567f9b3cc64218e6e425584894f78cd52"},"previous_names":["hongjungwan/http-handler-modules"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HongJungWan%2Fhttp-handler-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HongJungWan%2Fhttp-handler-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HongJungWan%2Fhttp-handler-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HongJungWan%2Fhttp-handler-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HongJungWan","download_url":"https://codeload.github.com/HongJungWan/http-handler-modules/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245864388,"owners_count":20685023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","github-action","go","golang","http","jwt","redis","testing"],"created_at":"2024-10-01T09:28:36.804Z","updated_at":"2025-03-27T14:44:16.853Z","avatar_url":"https://github.com/HongJungWan.png","language":"Go","readme":"# http-handler-modules\n\n## 프로젝트 목표\n\n* context 패키지나 database/sql 패키지 등의 필수 패키지 사용법\n\n\n* testing 패키지 외의 표준 패키지를 사용한 테스트 기법\n\n\n* 업계 표준이 된 외부 오픈소스\n\n\n* 누구나 한 번쯤은 코드 리뷰에서 지적당한 적이 있는 웹 애플리케이션을 구현할 때 발생할 수 있는 실수/실패\n\n\u003cbr\u003e\n\n위와 같은 내용을 학습한다.\n\n\u003cbr\u003e\u003cbr\u003e\n\n## 실습 내용\n\n| Title | Details                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| --- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| HTTP 서버 만들기 | 리팩터링 테스트 코드\u003cbr\u003e- 쉽지 않은 테스트\u003cbr\u003e- run 함수를 처리 분리하기\u003cbr\u003e- 테스트가 실행되지 않는 경우\u003cbr\u003e\u003cbr\u003e포트 번호를 변경할 수 있도록 만들기\u003cbr\u003e- 동적으로 포트 번호 설정하기\u003cbr\u003e                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n|  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| HTTP 서버를 약한 결합 구조로 변경하기 | 환경 변수로부터 설정 불러오기\u003cbr\u003e- Config 패키지 구현하기\u003cbr\u003e- 환경 변수를 사용해서 실행하기\u003cbr\u003e\u003cbr\u003e 시그널 처리하기\u003cbr\u003e- signal.NotifyContext를 사용해 시그널 기다리기\u003cbr\u003e\u003cbr\u003eServer 구조체 정의하기\u003cbr\u003e\u003cbr\u003e라우팅 정의를 분할한 NewMux 정의하기\u003cbr\u003e- httptest 패키지를 사용한 테스트\u003cbr\u003e\u003cbr\u003erun 함수를 다시 리팩터링하기\u003cbr\u003e                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n|  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| 엔드포인트 추가하기 | entity.Task 타입 정의와 영구 저장 방법의 임시 구현\u003cbr\u003e- entity.Task의 영구 저장 방법 임시 구현\u003cbr\u003e\u003cbr\u003e헬퍼 함수를 구현하기\u003cbr\u003e- 테스트용 헬퍼 함수 구현하기\u003cbr\u003e\u003cbr\u003e태스크를 등록하는 엔드포인트 구현\u003cbr\u003e- 요청 바디 검증\u003cbr\u003e\u003cbr\u003e테이블 주도 테스트와 골든 테스트를 조합한 테스트 코드\u003cbr\u003e\u003cbr\u003e태스크 목록을 반환하는 엔드포인트 구현\u003cbr\u003e\u003cbr\u003eHTTP 핸들러를 라우팅으로 설정하기\u003cbr\u003e- github.com/go-chi/chi를 사용한 유연한 라우팅 설정                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n|  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| RDBMS를 사용한 데이터베이스 처리 구현하기 | 테이블 정의와 마이그레이션 방법 검증\u003cbr\u003e- 마이그레이션 도구\u003cbr\u003e- 깃허브 액션에서 MySQL 컨테이너 실행하기\u003cbr\u003e\u003cbr\u003eRDBMS 처리 구현\u003cbr\u003e- database/sql과 github.com/jmoiron/sqlx 패키지 사용\u003cbr\u003e- 환경 변수에서 정보 읽기\u003cbr\u003e- 인터페이스와 Repository 타입 정의\u003cbr\u003e- RDBMS 관련 접근을 위한 테스트 템플릿 함수\u003cbr\u003e\u003cbr\u003eRDBMS 관련 접근을 위한 테스트 코드\u003cbr\u003e- 실행 환경에 따라 접속 정보를 변경하는 테스트 템플릿 함수\u003cbr\u003e- 실제 RDBMS를 사용한 테스트하기\u003cbr\u003e- 목을 사용한 테스트하기\u003cbr\u003e                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n|  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| 기능별로 HTTP 핸들러 구현 분할하기 | HTTP 핸들러 기능 분할\u003cbr\u003e\u003cbr\u003e go generate 명령을 사용한 목 자동 생성\u003cbr\u003e- github.com/matryer/moq 패키지\u003cbr\u003e\u003cbr\u003e목 코드 자동 생성\u003cbr\u003e- handler.AddTaskService를 사용한 handler.AddTask 리팩터링\u003cbr\u003e\u003cbr\u003e 사용자 등록 기능 작성\u003cbr\u003e- entity 패키지 구현\u003cbr\u003e- handler 패키지 구현\u003cbr\u003e- service 패키지 구현\u003cbr\u003e- store 패키지 구현\u003cbr\u003e- NewMux 함수에 로그인 엔드포인트 정의하기\u003cbr\u003e                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n|  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| 레디스와 JWT를 사용한 인증 및 권한 | 레디스 준비\u003cbr\u003e - 레디스를 사용하기 위한 애플리케이션 코드 준비\u003cbr\u003e- KVS 타입을 위한 테스트 작성\u003cbr\u003eJWT의 서명 준비\u003cbr\u003e- openssl 명령 준비\u003cbr\u003e- 비밀키와 공개키 생성\u003cbr\u003e\u003cbr\u003eJWT를 사용한 액세스 토큰 작성\u003cbr\u003e- JWTer 구조체 선언\u003cbr\u003e- go:embed를 사용한 파일 첨부하기\u003cbr\u003e- JWT를 발행하는 GenerationToken 메서드 구현\u003cbr\u003e- HTTP 요청에서 JWT 받기\u003cbr\u003e- JWT 정보를 context.Context 타입값에 넣기\u003cbr\u003e\u003cbr\u003e 사용자 로그인 엔드포인트 구현\u003cbr\u003e- handler 패키지 구현\u003cbr\u003e- service 패키지 구현\u003cbr\u003e- store 패키지 구현\u003cbr\u003e- NewMux 함수에 로그인 엔드포인트 정의하기\u003cbr\u003e\u003cbr\u003e 미들웨어 패턴을 사용한 인증 기능\u003cbr\u003e- http.Request의 context.Context 타입값에 사용자 ID와 관련된 정보 넣기\u003cbr\u003e- 요청 전송 사용자 admin 권한인지 검증하기\u003cbr\u003e\u003cbr\u003e 요청에 포함된 인증과 관련된 정보를 사용한 엔드포인트 보호\u003cbr\u003e- 테이블 정의 마이그레이션 작성\u003cbr\u003e- entity.Task 구조체 선언\u003cbr\u003e- 로그인 사용자만 태스크 추가하기\u003cbr\u003e- POST /tasks로 자신이 등록한 태스크만 추가\u003cbr\u003e- GET /tasks로 자신이 등록한 태스크만 보이도록 변경하기\u003cbr\u003e- admin 권한 사용자만 접근할 수 있는 엔드포인트 만들기 |\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Test Code Run\n\n```go\ngo test ./...\n\nor\n\ngo test -v ./...\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongjungwan%2Fhttp-handler-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhongjungwan%2Fhttp-handler-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongjungwan%2Fhttp-handler-modules/lists"}